@@ -67,6 +67,83 @@ TEST_CASE_FIXTURE(
6767 }));
6868}
6969
70+ TEST_CASE_FIXTURE (
71+ test_undirected_hyperedge_list,
72+ " bind(hyperedge, vertex) should add the vertex to the given hyperedge's storage only if the "
73+ " they are not bound"
74+ ) {
75+ sut_type sut{constants::n_vertices, constants::n_hyperedges};
76+ REQUIRE (std::ranges::empty (sut.hyperedge_vertices (constants::id1)));
77+
78+ sut.bind (constants::id1, constants::id1);
79+ const auto vertices1 = sut.hyperedge_vertices (constants::id1) | std::ranges::to<std::vector>();
80+ CHECK_EQ (std::ranges::size (vertices1), 1uz);
81+ CHECK (std::ranges::contains (vertices1, constants::id1));
82+ CHECK (std::ranges::equal (vertices1, storage (sut)[constants::id1]));
83+
84+ sut.bind (constants::id1, constants::id1);
85+ const auto vertices2 = sut.hyperedge_vertices (constants::id1) | std::ranges::to<std::vector>();
86+ CHECK_EQ (std::ranges::size (vertices2), 1uz);
87+ CHECK (std::ranges::equal (vertices2, vertices1));
88+ }
89+
90+ TEST_CASE_FIXTURE (
91+ test_undirected_hyperedge_list,
92+ " unbind(hyperedge, vertex) should remove the vertex from the given hyperedge's storage only if "
93+ " the they are bound"
94+ ) {
95+ sut_type sut{constants::n_vertices, constants::n_hyperedges};
96+ REQUIRE (std::ranges::empty (sut.hyperedge_vertices (constants::id1)));
97+
98+ sut.bind (constants::id1, constants::id1);
99+ const auto vertices1 = sut.hyperedge_vertices (constants::id1) | std::ranges::to<std::vector>();
100+ REQUIRE_EQ (std::ranges::size (vertices1), 1uz);
101+ REQUIRE (std::ranges::contains (vertices1, constants::id1));
102+
103+ sut.unbind (constants::id1, constants::id2);
104+ const auto vertices2 = sut.hyperedge_vertices (constants::id1) | std::ranges::to<std::vector>();
105+ REQUIRE_EQ (std::ranges::size (vertices2), 1uz);
106+ REQUIRE (std::ranges::equal (vertices2, vertices1));
107+
108+ sut.unbind (constants::id1, constants::id1);
109+ CHECK (std::ranges::empty (sut.hyperedge_vertices (constants::id1)));
110+ }
111+
112+ TEST_CASE_FIXTURE (
113+ test_undirected_hyperedge_list,
114+ " are_bound(hyperedge, vertex) should return true only when the given vertex is present in the "
115+ " hyperedge's storage"
116+ ) {
117+ sut_type sut{constants::n_vertices, constants::n_hyperedges};
118+ REQUIRE (std::ranges::empty (sut.hyperedge_vertices (constants::id1)));
119+
120+ sut.bind (constants::id1, constants::id1);
121+ const auto vertices1 = sut.hyperedge_vertices (constants::id1) | std::ranges::to<std::vector>();
122+ REQUIRE_EQ (std::ranges::size (vertices1), 1uz);
123+ REQUIRE (std::ranges::contains (vertices1, constants::id1));
124+
125+ CHECK (sut.are_bound (constants::id1, constants::id1));
126+ CHECK_FALSE (sut.are_bound (constants::id1, constants::id2));
127+ CHECK_FALSE (sut.are_bound (constants::id2, constants::id1));
128+ }
129+
130+ TEST_CASE_FIXTURE (
131+ test_undirected_hyperedge_list,
132+ " remove_vertex should unbind the given vertex from all hyperedges"
133+ ) {
134+ sut_type sut{constants::n_vertices, constants::n_hyperedges};
135+ for (const auto hyperedge_id : constants::hyperedge_ids_view)
136+ sut.bind (hyperedge_id, constants::id1);
137+ REQUIRE (std::ranges::all_of (constants::hyperedge_ids_view, [&sut](const auto hyperedge_id) {
138+ return sut.are_bound (hyperedge_id, constants::id1);
139+ }));
140+
141+ sut.remove_vertex (constants::id1);
142+ CHECK (std::ranges::all_of (constants::hyperedge_ids_view, [&sut](const auto hyperedge_id) {
143+ return std::ranges::empty (sut.hyperedge_vertices (hyperedge_id));
144+ }));
145+ }
146+
70147TEST_SUITE_END (); // test_hyperedge_list
71148
72149} // namespace hgl_testing
0 commit comments