Skip to content

Commit 7d92163

Browse files
committed
generic tests ext for flat-matrix
1 parent 635df30 commit 7d92163

3 files changed

Lines changed: 89 additions & 6 deletions

File tree

include/hgl/conversion.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ struct to_impl<impl::list_t<LayoutTag>, impl::flat_list_t<LayoutTag>> {
199199
}
200200
};
201201

202+
// TODO: matrix <-> flat-matrix specializations
203+
202204
} // namespace detail
203205

204206
/// @brief Converts a hypergraph from one implementation model to another.

tests/source/hgl/test_conversion.cpp

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@ TEST_CASE_TEMPLATE_DEFINE(
162162
using emajor_matrix_hypergraph =
163163
hgl::hypergraph<hgl::hypergraph_traits<DT, VP, EP, emajor_matrix_tag>>;
164164

165+
using vmajor_flat_matrix_tag = hgl::impl::flat_matrix_t<hgl::impl::vertex_major_t>;
166+
using emajor_flat_matrix_tag = hgl::impl::flat_matrix_t<hgl::impl::hyperedge_major_t>;
167+
168+
using vmajor_flat_matrix_hypergraph =
169+
hgl::hypergraph<hgl::hypergraph_traits<DT, VP, EP, vmajor_flat_matrix_tag>>;
170+
using emajor_flat_matrix_hypergraph =
171+
hgl::hypergraph<hgl::hypergraph_traits<DT, VP, EP, emajor_flat_matrix_tag>>;
172+
165173
test_hypergraph_conversion fixture;
166174

167175
auto test_conversion_for =
@@ -207,6 +215,16 @@ TEST_CASE_TEMPLATE_DEFINE(
207215
auto dst = hgl::to<emajor_matrix_tag>(std::move(src));
208216
fixture.validate_hypergraph(dst);
209217
}
218+
SUBCASE("to vertex-major flat-matrix") {
219+
auto src = fixture.create_test_hypergraph<Source>();
220+
auto dst = hgl::to<vmajor_flat_matrix_tag>(std::move(src));
221+
fixture.validate_hypergraph(dst);
222+
}
223+
SUBCASE("to hyperedge-major flat-matrix") {
224+
auto src = fixture.create_test_hypergraph<Source>();
225+
auto dst = hgl::to<emajor_flat_matrix_tag>(std::move(src));
226+
fixture.validate_hypergraph(dst);
227+
}
210228
}
211229
};
212230

@@ -232,6 +250,13 @@ TEST_CASE_TEMPLATE_DEFINE(
232250
test_conversion_for(
233251
std::type_identity<emajor_matrix_hypergraph>{}, "source: hyperedge-major matrix"
234252
);
253+
254+
test_conversion_for(
255+
std::type_identity<vmajor_flat_matrix_hypergraph>{}, "source: vertex-major flat-matrix"
256+
);
257+
test_conversion_for(
258+
std::type_identity<emajor_flat_matrix_hypergraph>{}, "source: hyperedge-major flat-matrix"
259+
);
235260
}
236261

237262
TEST_CASE_TEMPLATE_INSTANTIATE(
@@ -411,7 +436,13 @@ TEST_CASE_TEMPLATE_INSTANTIATE(
411436
hgl::undirected_t>, // hyperedge-major incidence matrix
412437
hgl::matrix_hypergraph_traits<
413438
hgl::impl::vertex_major_t,
414-
hgl::undirected_t> // vertex-major incidence matrix
439+
hgl::undirected_t>, // vertex-major incidence matrix
440+
hgl::flat_matrix_hypergraph_traits<
441+
hgl::impl::hyperedge_major_t,
442+
hgl::undirected_t>, // hyperedge-major flat incidence matrix
443+
hgl::flat_matrix_hypergraph_traits<
444+
hgl::impl::vertex_major_t,
445+
hgl::undirected_t> // vertex-major flat incidence matrix
415446
);
416447

417448
TEST_CASE_TEMPLATE_DEFINE(
@@ -547,7 +578,13 @@ TEST_CASE_TEMPLATE_INSTANTIATE(
547578
hgl::bf_directed_t>, // hyperedge-major incidence matrix
548579
hgl::matrix_hypergraph_traits<
549580
hgl::impl::vertex_major_t,
550-
hgl::bf_directed_t> // vertex-major incidence matrix
581+
hgl::bf_directed_t>, // vertex-major incidence matrix
582+
hgl::flat_matrix_hypergraph_traits<
583+
hgl::impl::hyperedge_major_t,
584+
hgl::bf_directed_t>, // hyperedge-major flat incidence matrix
585+
hgl::flat_matrix_hypergraph_traits<
586+
hgl::impl::vertex_major_t,
587+
hgl::bf_directed_t> // vertex-major flat incidence matrix
551588
);
552589

553590
TEST_SUITE_END(); // test_converters

tests/source/hgl/test_hypergraph.cpp

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,12 @@ TEST_CASE_TEMPLATE_INSTANTIATE(
935935
hgl::matrix_hypergraph_traits<
936936
hgl::impl::vertex_major_t,
937937
hgl::undirected_t>, // undirected vertex-major incidence matrix
938+
hgl::flat_matrix_hypergraph_traits<
939+
hgl::impl::hyperedge_major_t,
940+
hgl::undirected_t>, // undirected hyperedge-major flat incidence matrix
941+
hgl::flat_matrix_hypergraph_traits<
942+
hgl::impl::vertex_major_t,
943+
hgl::undirected_t>, // undirected vertex-major flat incidence matrix
938944
hgl::list_hypergraph_traits<
939945
hgl::impl::bidirectional_t,
940946
hgl::bf_directed_t>, // bf-directed bidirectional incidence list
@@ -958,7 +964,13 @@ TEST_CASE_TEMPLATE_INSTANTIATE(
958964
hgl::bf_directed_t>, // bf-directed hyperedge-major incidence matrix
959965
hgl::matrix_hypergraph_traits<
960966
hgl::impl::vertex_major_t,
961-
hgl::bf_directed_t> // bf-directed vertex-major incidence matrix
967+
hgl::bf_directed_t>, // bf-directed vertex-major incidence matrix
968+
hgl::flat_matrix_hypergraph_traits<
969+
hgl::impl::hyperedge_major_t,
970+
hgl::bf_directed_t>, // bf-directed hyperedge-major flat incidence matrix
971+
hgl::flat_matrix_hypergraph_traits<
972+
hgl::impl::vertex_major_t,
973+
hgl::bf_directed_t> // bf-directed vertex-major flat incidence matrix
962974
);
963975

964976
TEST_CASE_TEMPLATE_DEFINE(
@@ -1120,7 +1132,17 @@ TEST_CASE_TEMPLATE_INSTANTIATE(
11201132
hgl::impl::vertex_major_t,
11211133
hgl::undirected_t,
11221134
hgl::name_property,
1123-
hgl::name_property> // undirected vertex-major incidence matrix
1135+
hgl::name_property>, // undirected vertex-major incidence matrix
1136+
hgl::flat_matrix_hypergraph_traits<
1137+
hgl::impl::hyperedge_major_t,
1138+
hgl::undirected_t,
1139+
hgl::name_property,
1140+
hgl::name_property>, // undirected hyperedge-major flat incidence matrix
1141+
hgl::flat_matrix_hypergraph_traits<
1142+
hgl::impl::vertex_major_t,
1143+
hgl::undirected_t,
1144+
hgl::name_property,
1145+
hgl::name_property> // undirected vertex-major flat incidence matrix
11241146
);
11251147

11261148
TEST_CASE_TEMPLATE_DEFINE(
@@ -1356,7 +1378,17 @@ TEST_CASE_TEMPLATE_INSTANTIATE(
13561378
hgl::impl::vertex_major_t,
13571379
hgl::bf_directed_t,
13581380
hgl::name_property,
1359-
hgl::name_property> // bf-directed vertex-major incidence matrix
1381+
hgl::name_property>, // bf-directed vertex-major incidence matrix
1382+
hgl::flat_matrix_hypergraph_traits<
1383+
hgl::impl::hyperedge_major_t,
1384+
hgl::bf_directed_t,
1385+
hgl::name_property,
1386+
hgl::name_property>, // bf-directed hyperedge-major flat incidence matrix
1387+
hgl::flat_matrix_hypergraph_traits<
1388+
hgl::impl::vertex_major_t,
1389+
hgl::bf_directed_t,
1390+
hgl::name_property,
1391+
hgl::name_property> // bf-directed vertex-major flat incidence matrix
13601392
);
13611393

13621394
TEST_CASE_TEMPLATE_DEFINE(
@@ -1557,6 +1589,12 @@ TEST_CASE_TEMPLATE_INSTANTIATE(
15571589
hgl::matrix_hypergraph_traits<
15581590
hgl::impl::vertex_major_t,
15591591
hgl::undirected_t>, // undirected vertex-major incidence matrix
1592+
hgl::flat_matrix_hypergraph_traits<
1593+
hgl::impl::hyperedge_major_t,
1594+
hgl::undirected_t>, // undirected hyperedge-major flat incidence matrix
1595+
hgl::flat_matrix_hypergraph_traits<
1596+
hgl::impl::vertex_major_t,
1597+
hgl::undirected_t>, // undirected vertex-major flat incidence matrix
15601598
hgl::list_hypergraph_traits<
15611599
hgl::impl::bidirectional_t,
15621600
hgl::bf_directed_t>, // bf-directed bidirectional incidence list
@@ -1580,7 +1618,13 @@ TEST_CASE_TEMPLATE_INSTANTIATE(
15801618
hgl::bf_directed_t>, // bf-directed hyperedge-major incidence matrix
15811619
hgl::matrix_hypergraph_traits<
15821620
hgl::impl::vertex_major_t,
1583-
hgl::bf_directed_t> // bf-directed vertex-major incidence matrix
1621+
hgl::bf_directed_t>, // bf-directed vertex-major incidence matrix
1622+
hgl::flat_matrix_hypergraph_traits<
1623+
hgl::impl::hyperedge_major_t,
1624+
hgl::bf_directed_t>, // bf-directed hyperedge-major flat incidence matrix
1625+
hgl::flat_matrix_hypergraph_traits<
1626+
hgl::impl::vertex_major_t,
1627+
hgl::bf_directed_t> // bf-directed vertex-major flat incidence matrix
15841628
);
15851629

15861630
TEST_SUITE_END(); // test_hypergraph

0 commit comments

Comments
 (0)