Skip to content

Commit eff914f

Browse files
committed
other tests
1 parent 048a847 commit eff914f

5 files changed

Lines changed: 132 additions & 375 deletions

File tree

tests/source/hgl/test_alg_backward_search.cpp

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,9 @@ TEST_CASE_TEMPLATE_DEFINE(
4141

4242
const auto order = 5uz;
4343
hypergraph.add_vertices(order);
44-
45-
const auto e0 = hypergraph.add_hyperedge().id();
46-
hypergraph.bind_tail(0uz, e0);
47-
hypergraph.bind_tail(1uz, e0);
48-
hypergraph.bind_head(2uz, e0);
49-
50-
const auto e1 = hypergraph.add_hyperedge().id();
51-
hypergraph.bind_tail(2uz, e1);
52-
hypergraph.bind_head(3uz, e1);
53-
hypergraph.bind_head(4uz, e1);
54-
55-
const auto e2 = hypergraph.add_hyperedge().id();
56-
hypergraph.bind_tail(1uz, e2);
57-
hypergraph.bind_head(4uz, e2);
44+
const auto e0 = hypergraph.add_hyperedge({0u, 1u}, {2u}).id();
45+
const auto e1 = hypergraph.add_hyperedge({2u}, {3u, 4u}).id();
46+
const auto e2 = hypergraph.add_hyperedge({1u}, {4u}).id();
5847

5948
SUBCASE("single root v0 (immediate halt)") {
6049
root_vertices = {0u};
@@ -191,20 +180,9 @@ TEST_CASE_TEMPLATE_DEFINE(
191180

192181
const auto order = 5uz;
193182
hypergraph.add_vertices(order);
194-
195-
const auto e0 = hypergraph.add_hyperedge().id();
196-
hypergraph.bind_tail(0uz, e0);
197-
hypergraph.bind_tail(1uz, e0);
198-
hypergraph.bind_head(2uz, e0);
199-
200-
const auto e1 = hypergraph.add_hyperedge().id();
201-
hypergraph.bind_tail(2uz, e1);
202-
hypergraph.bind_head(3uz, e1);
203-
hypergraph.bind_head(4uz, e1);
204-
205-
const auto e2 = hypergraph.add_hyperedge().id();
206-
hypergraph.bind_tail(1uz, e2);
207-
hypergraph.bind_head(4uz, e2);
183+
const auto e0 = hypergraph.add_hyperedge({0u, 1u}, {2u}).id();
184+
const auto e1 = hypergraph.add_hyperedge({2u}, {3u, 4u}).id();
185+
const auto e2 = hypergraph.add_hyperedge({1u}, {4u}).id();
208186

209187
SUBCASE("single root v0 (immediate halt)") {
210188
root_vertices = {0u};

tests/source/hgl/test_alg_bfs.cpp

Lines changed: 24 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ TEST_CASE_TEMPLATE_DEFINE(
3131

3232
SUBCASE("hub (single hyperedge)") {
3333
hypergraph.add_vertices(4uz);
34-
const auto e = hypergraph.add_hyperedge().id();
35-
for (const auto v : hypergraph.vertex_ids())
36-
hypergraph.bind(v, e);
34+
const auto e = hypergraph.add_hyperedge(hypergraph.vertex_ids()).id();
3735

3836
root_vertex_id = hgl::initial_id;
3937

@@ -46,18 +44,9 @@ TEST_CASE_TEMPLATE_DEFINE(
4644
SUBCASE("chain") {
4745
// E(H) = {{0, 1}, {1, 2, 3}, {3, 4, 5}}
4846
hypergraph.add_vertices(6uz);
49-
50-
const auto e0 = hypergraph.add_hyperedge().id();
51-
for (const id_type v : {0u, 1u})
52-
hypergraph.bind(v, e0);
53-
54-
const auto e1 = hypergraph.add_hyperedge().id();
55-
for (const id_type v : {1u, 2u, 3u})
56-
hypergraph.bind(v, e1);
57-
58-
const auto e2 = hypergraph.add_hyperedge().id();
59-
for (const id_type v : {3u, 4u, 5u})
60-
hypergraph.bind(v, e2);
47+
const auto e0 = hypergraph.add_hyperedge({0u, 1u}).id();
48+
const auto e1 = hypergraph.add_hyperedge({1u, 2u, 3u}).id();
49+
const auto e2 = hypergraph.add_hyperedge({3u, 4u, 5u}).id();
6150

6251
root_vertex_id = hgl::initial_id;
6352

@@ -70,22 +59,10 @@ TEST_CASE_TEMPLATE_DEFINE(
7059
SUBCASE("overlapping hyperedges (shortest path preference)") {
7160
// E(H) = {{0, 1}, {1, 2, 3}, {0, 3}, {3, 4}}
7261
hypergraph.add_vertices(5uz);
73-
74-
const auto e0 = hypergraph.add_hyperedge().id();
75-
for (const id_type v : {0u, 1u})
76-
hypergraph.bind(v, e0);
77-
78-
const auto e1 = hypergraph.add_hyperedge().id();
79-
for (const id_type v : {1u, 2u, 3u})
80-
hypergraph.bind(v, e1);
81-
82-
const auto e2 = hypergraph.add_hyperedge().id();
83-
for (const id_type v : {0u, 3u})
84-
hypergraph.bind(v, e2);
85-
86-
const auto e3 = hypergraph.add_hyperedge().id();
87-
for (const id_type v : {3u, 4u})
88-
hypergraph.bind(v, e3);
62+
const auto e0 = hypergraph.add_hyperedge({0u, 1u}).id();
63+
const auto e1 = hypergraph.add_hyperedge({1u, 2u, 3u}).id();
64+
const auto e2 = hypergraph.add_hyperedge({0u, 3u}).id();
65+
const auto e3 = hypergraph.add_hyperedge({3u, 4u}).id();
8966

9067
root_vertex_id = hgl::initial_id;
9168

@@ -99,14 +76,8 @@ TEST_CASE_TEMPLATE_DEFINE(
9976
SUBCASE("disconnected components (targeted root)") {
10077
// E(H) = {{0, 1, 2}, {3, 4}}
10178
hypergraph.add_vertices(5uz);
102-
103-
const auto e0 = hypergraph.add_hyperedge().id();
104-
for (const id_type v : {0u, 1u, 2u})
105-
hypergraph.bind(v, e0);
106-
107-
const auto e1 = hypergraph.add_hyperedge().id();
108-
for (const id_type v : {3u, 4u})
109-
hypergraph.bind(v, e1);
79+
const auto e0 = hypergraph.add_hyperedge({0u, 1u, 2u}).id();
80+
hypergraph.add_hyperedge({3u, 4u});
11081

11182
root_vertex_id = hgl::initial_id;
11283

@@ -119,14 +90,8 @@ TEST_CASE_TEMPLATE_DEFINE(
11990
SUBCASE("full graph traversal (no_root)") {
12091
// E(H) = {{0, 1, 2}, {3, 4}}
12192
hypergraph.add_vertices(5uz);
122-
123-
const auto e0 = hypergraph.add_hyperedge().id();
124-
for (const id_type v : {0u, 1u, 2u})
125-
hypergraph.bind(v, e0);
126-
127-
const auto e1 = hypergraph.add_hyperedge().id();
128-
for (const id_type v : {3u, 4u})
129-
hypergraph.bind(v, e1);
93+
const auto e0 = hypergraph.add_hyperedge({0u, 1u, 2u}).id();
94+
const auto e1 = hypergraph.add_hyperedge({3u, 4u}).id();
13095

13196
root_vertex_id = hgl::algorithm::no_root;
13297

@@ -242,11 +207,7 @@ TEST_CASE_TEMPLATE_DEFINE(
242207
SUBCASE("forward star (single hyperedge)") {
243208
// E(H) = {0->{1, 2, 3}}
244209
hypergraph.add_vertices(4uz);
245-
const auto e = hypergraph.add_hyperedge().id();
246-
247-
hypergraph.bind_tail(0uz, e);
248-
for (const id_type v : {1u, 2u, 3u})
249-
hypergraph.bind_head(v, e);
210+
const auto e = hypergraph.add_hyperedge({0u}, {1u, 2u, 3u}).id();
250211

251212
root_vertex_id = hgl::initial_id;
252213

@@ -259,20 +220,9 @@ TEST_CASE_TEMPLATE_DEFINE(
259220
SUBCASE("chain") {
260221
// E(H) = {0->1, 1->{2, 3}, 3->{4, 5}}
261222
hypergraph.add_vertices(6uz);
262-
263-
const auto e0 = hypergraph.add_hyperedge().id();
264-
hypergraph.bind_tail(0uz, e0);
265-
hypergraph.bind_head(1uz, e0);
266-
267-
const auto e1 = hypergraph.add_hyperedge().id();
268-
hypergraph.bind_tail(1uz, e1);
269-
for (const id_type v : {2u, 3u})
270-
hypergraph.bind_head(v, e1);
271-
272-
const auto e2 = hypergraph.add_hyperedge().id();
273-
hypergraph.bind_tail(3uz, e2);
274-
for (const id_type v : {4u, 5u})
275-
hypergraph.bind_head(v, e2);
223+
const auto e0 = hypergraph.add_hyperedge({0u}, {1u}).id();
224+
const auto e1 = hypergraph.add_hyperedge({1u}, {2u, 3u}).id();
225+
const auto e2 = hypergraph.add_hyperedge({3u}, {4u, 5u}).id();
276226

277227
root_vertex_id = hgl::initial_id;
278228

@@ -285,23 +235,10 @@ TEST_CASE_TEMPLATE_DEFINE(
285235
SUBCASE("overlapping hyperedges (shortest path preference)") {
286236
// E(H) = {0->1, 1->{2, 3}, 0->3 (shortcut!), 3->4}
287237
hypergraph.add_vertices(5uz);
288-
289-
const auto e0 = hypergraph.add_hyperedge().id();
290-
hypergraph.bind_tail(0uz, e0);
291-
hypergraph.bind_head(1uz, e0);
292-
293-
const auto e1 = hypergraph.add_hyperedge().id();
294-
hypergraph.bind_tail(1uz, e1);
295-
for (const id_type v : {2u, 3u})
296-
hypergraph.bind_head(v, e1);
297-
298-
const auto e2 = hypergraph.add_hyperedge().id();
299-
hypergraph.bind_tail(0uz, e2);
300-
hypergraph.bind_head(3uz, e2);
301-
302-
const auto e3 = hypergraph.add_hyperedge().id();
303-
hypergraph.bind_tail(3uz, e3);
304-
hypergraph.bind_head(4uz, e3);
238+
const auto e0 = hypergraph.add_hyperedge({0u}, {1u}).id();
239+
const auto e1 = hypergraph.add_hyperedge({1u}, {2u, 3u}).id();
240+
const auto e2 = hypergraph.add_hyperedge({0u}, {3u}).id();
241+
const auto e3 = hypergraph.add_hyperedge({3u}, {4u}).id();
305242

306243
root_vertex_id = hgl::initial_id;
307244

@@ -315,15 +252,8 @@ TEST_CASE_TEMPLATE_DEFINE(
315252
SUBCASE("disconnected components (targeted root)") {
316253
// E(H) = {0->{1, 2}, 3->4}
317254
hypergraph.add_vertices(5uz);
318-
319-
const auto e0 = hypergraph.add_hyperedge().id();
320-
hypergraph.bind_tail(0uz, e0);
321-
for (const id_type v : {1u, 2u})
322-
hypergraph.bind_head(v, e0);
323-
324-
const auto e1 = hypergraph.add_hyperedge().id();
325-
hypergraph.bind_tail(3uz, e1);
326-
hypergraph.bind_head(4uz, e1);
255+
const auto e0 = hypergraph.add_hyperedge({0u}, {1u, 2u}).id();
256+
hypergraph.add_hyperedge({3u}, {4u});
327257

328258
root_vertex_id = hgl::initial_id;
329259

@@ -336,15 +266,8 @@ TEST_CASE_TEMPLATE_DEFINE(
336266
SUBCASE("full graph traversal (no_root)") {
337267
// E(H) = {0->{1, 2}, 3->4}
338268
hypergraph.add_vertices(5uz);
339-
340-
const auto e0 = hypergraph.add_hyperedge().id();
341-
hypergraph.bind_tail(0uz, e0);
342-
for (const id_type v : {1u, 2u})
343-
hypergraph.bind_head(v, e0);
344-
345-
const auto e1 = hypergraph.add_hyperedge().id();
346-
hypergraph.bind_tail(3uz, e1);
347-
hypergraph.bind_head(4uz, e1);
269+
const auto e0 = hypergraph.add_hyperedge({0u}, {1u, 2u}).id();
270+
const auto e1 = hypergraph.add_hyperedge({3u}, {4u}).id();
348271

349272
root_vertex_id = hgl::algorithm::no_root;
350273

0 commit comments

Comments
 (0)