Skip to content

Commit 7703f49

Browse files
committed
tests ext
1 parent 1f2cf4b commit 7703f49

3 files changed

Lines changed: 110 additions & 13 deletions

File tree

include/hgl/hypergraph_traits.hpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ using matrix_hypergraph_traits = hypergraph_traits<
6666
HyperedgeProperties,
6767
impl::matrix_t<LayoutTag, IdType>>;
6868

69+
template <
70+
traits::c_hypergraph_asymmetric_layout_tag LayoutTag = impl::hyperedge_major_t,
71+
traits::c_hypergraph_directional_tag DirectionalTag = undirected_t,
72+
traits::c_properties VertexProperties = empty_properties,
73+
traits::c_properties HyperedgeProperties = empty_properties,
74+
traits::c_id_type IdType = default_id_type>
75+
using flat_matrix_hypergraph_traits = hypergraph_traits<
76+
DirectionalTag,
77+
VertexProperties,
78+
HyperedgeProperties,
79+
impl::flat_matrix_t<LayoutTag, IdType>>;
80+
6981
template <
7082
traits::c_properties VertexProperties = empty_properties,
7183
traits::c_properties HyperedgeProperties = empty_properties,
@@ -101,8 +113,14 @@ concept c_matrix_hypergraph_traits =
101113
c_instantiation_of<TraitsType, hypergraph_traits>
102114
and c_hypergraph_matrix_impl<typename TraitsType::implementation_tag>;
103115

104-
template <typename TypeTraits>
105-
concept c_incidence_matrix_hypergraph_traits = c_matrix_hypergraph_traits<TypeTraits>;
116+
template <typename TraitsType>
117+
concept c_flat_matrix_hypergraph_traits =
118+
c_instantiation_of<TraitsType, hypergraph_traits>
119+
and c_hypergraph_flat_matrix_impl<typename TraitsType::implementation_tag>;
120+
121+
template <typename TraitsType>
122+
concept c_incidence_matrix_hypergraph_traits =
123+
c_matrix_hypergraph_traits<TraitsType> or c_flat_matrix_hypergraph_traits<TraitsType>;
106124

107125
template <typename TraitsType>
108126
concept c_undirected_hypergraph_traits =

tests/source/hgl/test_conversion.cpp

Lines changed: 38 additions & 7 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(
@@ -403,15 +428,15 @@ TEST_CASE_TEMPLATE_INSTANTIATE(
403428
hgl::flat_list_hypergraph_traits<
404429
hgl::impl::hyperedge_major_t,
405430
hgl::undirected_t>, // undirected hyperedge-major flat incidence list
406-
hgl::flat_list_hypergraph_traits<
407-
hgl::impl::vertex_major_t,
408-
hgl::undirected_t>, // undirected vertex-major flat incidence list
409431
hgl::matrix_hypergraph_traits<
432+
hgl::impl::vertex_major_t,
433+
hgl::undirected_t>, // vertex-major incidence matrix
434+
hgl::flat_matrix_hypergraph_traits<
410435
hgl::impl::hyperedge_major_t,
411-
hgl::undirected_t>, // hyperedge-major incidence matrix
412-
hgl::matrix_hypergraph_traits<
436+
hgl::undirected_t>, // hyperedge-major flat incidence matrix
437+
hgl::flat_matrix_hypergraph_traits<
413438
hgl::impl::vertex_major_t,
414-
hgl::undirected_t> // vertex-major incidence matrix
439+
hgl::undirected_t> // vertex-major flat incidence matrix
415440
);
416441

417442
TEST_CASE_TEMPLATE_DEFINE(
@@ -547,7 +572,13 @@ TEST_CASE_TEMPLATE_INSTANTIATE(
547572
hgl::bf_directed_t>, // hyperedge-major incidence matrix
548573
hgl::matrix_hypergraph_traits<
549574
hgl::impl::vertex_major_t,
550-
hgl::bf_directed_t> // vertex-major incidence matrix
575+
hgl::bf_directed_t>, // vertex-major incidence matrix
576+
hgl::flat_matrix_hypergraph_traits<
577+
hgl::impl::hyperedge_major_t,
578+
hgl::bf_directed_t>, // hyperedge-major flat incidence matrix
579+
hgl::flat_matrix_hypergraph_traits<
580+
hgl::impl::vertex_major_t,
581+
hgl::bf_directed_t> // vertex-major flat incidence matrix
551582
);
552583

553584
TEST_SUITE_END(); // test_converters

tests/source/hgl/test_hypergraph.cpp

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,8 @@ TEST_CASE_TEMPLATE_DEFINE(
391391

392392
SUBCASE("bind, unbind and are_incident should throw if either of the fiven elements is invalid"
393393
) {
394+
GL_SUPPRESS_WARNING_BEGIN("-Warray-bounds");
395+
394396
sut_type sut{constants::n_vertices, constants::n_hyperedges};
395397

396398
if constexpr (std::same_as<directional_tag, hgl::undirected_t>) {
@@ -474,6 +476,8 @@ TEST_CASE_TEMPLATE_DEFINE(
474476
std::out_of_range
475477
);
476478
}
479+
480+
GL_SUPPRESS_WARNING_END;
477481
}
478482

479483
SUBCASE("are_incident should return false by default") {
@@ -944,6 +948,12 @@ TEST_CASE_TEMPLATE_INSTANTIATE(
944948
hgl::matrix_hypergraph_traits<
945949
hgl::impl::vertex_major_t,
946950
hgl::undirected_t>, // undirected vertex-major incidence matrix
951+
hgl::flat_matrix_hypergraph_traits<
952+
hgl::impl::hyperedge_major_t,
953+
hgl::undirected_t>, // undirected hyperedge-major flat incidence matrix
954+
hgl::flat_matrix_hypergraph_traits<
955+
hgl::impl::vertex_major_t,
956+
hgl::undirected_t>, // undirected vertex-major flat incidence matrix
947957
hgl::list_hypergraph_traits<
948958
hgl::impl::bidirectional_t,
949959
hgl::bf_directed_t>, // bf-directed bidirectional incidence list
@@ -967,7 +977,13 @@ TEST_CASE_TEMPLATE_INSTANTIATE(
967977
hgl::bf_directed_t>, // bf-directed hyperedge-major incidence matrix
968978
hgl::matrix_hypergraph_traits<
969979
hgl::impl::vertex_major_t,
970-
hgl::bf_directed_t> // bf-directed vertex-major incidence matrix
980+
hgl::bf_directed_t>, // bf-directed vertex-major incidence matrix
981+
hgl::flat_matrix_hypergraph_traits<
982+
hgl::impl::hyperedge_major_t,
983+
hgl::bf_directed_t>, // bf-directed hyperedge-major flat incidence matrix
984+
hgl::flat_matrix_hypergraph_traits<
985+
hgl::impl::vertex_major_t,
986+
hgl::bf_directed_t> // bf-directed vertex-major flat incidence matrix
971987
);
972988

973989
TEST_CASE_TEMPLATE_DEFINE(
@@ -1129,7 +1145,17 @@ TEST_CASE_TEMPLATE_INSTANTIATE(
11291145
hgl::impl::vertex_major_t,
11301146
hgl::undirected_t,
11311147
hgl::name_property,
1132-
hgl::name_property> // undirected vertex-major incidence matrix
1148+
hgl::name_property>, // undirected vertex-major incidence matrix
1149+
hgl::flat_matrix_hypergraph_traits<
1150+
hgl::impl::hyperedge_major_t,
1151+
hgl::undirected_t,
1152+
hgl::name_property,
1153+
hgl::name_property>, // undirected hyperedge-major flat incidence matrix
1154+
hgl::flat_matrix_hypergraph_traits<
1155+
hgl::impl::vertex_major_t,
1156+
hgl::undirected_t,
1157+
hgl::name_property,
1158+
hgl::name_property> // undirected vertex-major flat incidence matrix
11331159
);
11341160

11351161
TEST_CASE_TEMPLATE_DEFINE(
@@ -1365,7 +1391,17 @@ TEST_CASE_TEMPLATE_INSTANTIATE(
13651391
hgl::impl::vertex_major_t,
13661392
hgl::bf_directed_t,
13671393
hgl::name_property,
1368-
hgl::name_property> // bf-directed vertex-major incidence matrix
1394+
hgl::name_property>, // bf-directed vertex-major incidence matrix
1395+
hgl::flat_matrix_hypergraph_traits<
1396+
hgl::impl::hyperedge_major_t,
1397+
hgl::bf_directed_t,
1398+
hgl::name_property,
1399+
hgl::name_property>, // bf-directed hyperedge-major flat incidence matrix
1400+
hgl::flat_matrix_hypergraph_traits<
1401+
hgl::impl::vertex_major_t,
1402+
hgl::bf_directed_t,
1403+
hgl::name_property,
1404+
hgl::name_property> // bf-directed vertex-major flat incidence matrix
13691405
);
13701406

13711407
TEST_CASE_TEMPLATE_DEFINE(
@@ -1566,6 +1602,12 @@ TEST_CASE_TEMPLATE_INSTANTIATE(
15661602
hgl::matrix_hypergraph_traits<
15671603
hgl::impl::vertex_major_t,
15681604
hgl::undirected_t>, // undirected vertex-major incidence matrix
1605+
hgl::flat_matrix_hypergraph_traits<
1606+
hgl::impl::hyperedge_major_t,
1607+
hgl::undirected_t>, // undirected hyperedge-major flat incidence matrix
1608+
hgl::flat_matrix_hypergraph_traits<
1609+
hgl::impl::vertex_major_t,
1610+
hgl::undirected_t>, // undirected vertex-major flat incidence matrix
15691611
hgl::list_hypergraph_traits<
15701612
hgl::impl::bidirectional_t,
15711613
hgl::bf_directed_t>, // bf-directed bidirectional incidence list
@@ -1589,7 +1631,13 @@ TEST_CASE_TEMPLATE_INSTANTIATE(
15891631
hgl::bf_directed_t>, // bf-directed hyperedge-major incidence matrix
15901632
hgl::matrix_hypergraph_traits<
15911633
hgl::impl::vertex_major_t,
1592-
hgl::bf_directed_t> // bf-directed vertex-major incidence matrix
1634+
hgl::bf_directed_t>, // bf-directed vertex-major incidence matrix
1635+
hgl::flat_matrix_hypergraph_traits<
1636+
hgl::impl::hyperedge_major_t,
1637+
hgl::bf_directed_t>, // bf-directed hyperedge-major flat incidence matrix
1638+
hgl::flat_matrix_hypergraph_traits<
1639+
hgl::impl::vertex_major_t,
1640+
hgl::bf_directed_t> // bf-directed vertex-major flat incidence matrix
15931641
);
15941642

15951643
TEST_SUITE_END(); // test_hypergraph

0 commit comments

Comments
 (0)