14namespace sequoia::testing
16 namespace undirected_graph{
20 nodew = graph_description::end,
65 node_1_1_1w_1w_node_0w_0w_0_0,
71 node_0w_1_1_1w_1w_node_0w_0w_0_0
79 class EdgeStorageConfig,
80 class NodeWeightStorage
86 using edge_t =
typename graph_t::edge_init_type;
87 using node_weight_type =
typename graph_t::node_weight_type;
88 using edges_equivalent_t = std::initializer_list<std::initializer_list<edge_t>>;
93 auto trg{make_weighted_transition_graph(t)};
96 [&t](std::string_view description,
const graph_t& obtained,
const graph_t& prediction,
const graph_t& parent, std::size_t host, std::size_t target) {
97 t.check(equality, {description, no_source_location}, obtained, prediction);
98 if(host != target) t.check_semantics({description, no_source_location}, prediction, parent);
106 static graph_t make_and_check(
regular_test& t, std::string_view description, edges_equivalent_t edgeInit, std::initializer_list<node_weight_type> nodeInit)
111 static void check_initialization_exceptions(
regular_test& t)
113 using nodes = std::initializer_list<node_weight_type>;
116 t.check_exception_thrown<std::logic_error>(
"Mismatched loop weights", [](){
return graph_t{{edge_t{0, 1.0, 1.0}, edge_t{0, 1.0, 2.0}}}; });
119 t.check_exception_thrown<std::logic_error>(
"Mismatched weights", [](){
return graph_t{{edge_t{1, 1.0, 2.0}}, {edge_t{0, 2.0, 1.0}}}; });
121 t.check_exception_thrown<std::logic_error>(
"Mismatched edge/node initialization", [](){
return graph_t{{}, nodes{1.0}}; });
122 t.check_exception_thrown<std::logic_error>(
"Mismatched edge/node initialization", [](){
return graph_t{{{}}, nodes{1.0, 2.0}}; });
123 t.check_exception_thrown<std::logic_error>(
"Mismatched edge/node initialization", [](){
return graph_t{{{edge_t{0, 1.0, -1.2}, edge_t{0, 1.0, -1.2}}}, nodes{1.0, 2.0}}; });
124 t.check_exception_thrown<std::logic_error>(
"Mismatched edge/node initialization", [](){
return graph_t{{{}, {}}, nodes{1.0}}; });
125 t.check_exception_thrown<std::logic_error>(
"Mismatched edge/node initialization", [](){
return graph_t{{{edge_t{1}}, {edge_t{0}}}, nodes{1.0}}; });
129 static transition_graph make_weighted_transition_graph(
regular_test& t)
134 auto trg{base_ops::make_transition_graph(t)};
136 check_initialization_exceptions(t);
139 trg.add_node(make_and_check(t, t.report(
""), {{}}, {{1.0, -1.0}}));
142 trg.add_node(make_and_check(t, t.report(
""), {{{0, 1.0, -1.0}, {0, 1.0, -1.0}}}, {{0.0}}));
145 trg.add_node(make_and_check(t, t.report(
""), {{{0, 1.0, -1.0}, {0, 1.0, -1.0}, {0, 1.0, -1.0}, {0, 1.0, -1.0}}}, {{0.0}}));
150 auto g{make_and_check(t, t.report(
""), {{{0, 0.0, 0.0}, {0, 0.0, 0.0}, {0, 1.0, -1.0}, {0, 1.0, -1.0}}}, {{0.0}})};
151 t.check(equality,
"Canonical ordering of weighted edges", graph_t{{{{0, 0.0, 0.0}, {0, 1.0, -1.0}, {0, 0.0, 0.0}, {0, 1.0, -1.0}}}, {{0.0}}}, g);
158 auto g{make_and_check(t, t.report(
""), {{{0, 1.0, -1.0}, {0, 1.0, -1.0}, {0, 0.0, 0.0}, {0, 0.0, 0.0}}}, {{0.0}})};
159 t.check(equality,
"Canonical ordering of weighted edges", graph_t{{{{0, 1.0, -1.0}, {0, 0.0, 0.0}, {0, 0.0, 0.0}, {0, 1.0, -1.0}}}, {{0.0}}}, g);
164 trg.add_node(make_and_check(t, t.report(
""), {{{0, 1.0, -1.0}, {0, 1.0, -1.0}, {1, 0.0, 0.0}}, {{0, 0.0, 0.0}}}, {{}, {}}));
169 auto g{make_and_check(t, t.report(
""), {{{0, 1.0, -1.0}, {0, 1.0, -1.0}, {1, 0.0, 0.0}}, {{0, 0.0, 0.0}}}, {{}, {}})};
170 t.check(equality,
"Canonical ordering of weighted edges", graph_t{{{{0, 1.0, -1.0}, {1, 0.0, 0.0}, {0, 1.0, -1.0}}, {{0, 0.0, 0.0}}}, {{}, {}}}, g);
177 auto g{make_and_check(t, t.report(
""), {{{1, 0.0, 0.0}}, {{0, 0.0, 0.0}, {1, 1.0, -1.0}, {1, 1.0, -1.0}}}, {{}, {}})};
178 t.check(equality,
"Canonical ordering of weighted edges", graph_t{{{{1, 0.0, 0.0}}, {{1, 1.0, -1.0}, {0, 0.0, 0.0}, {1, 1.0, -1.0}}}, {{}, {}}}, g);
183 trg.add_node(make_and_check(t, t.report(
""), {{{1, 0.0, 0.0}, {1, 1.0, -1.0}}, {{0, 0.0, 0.0}, {0, 1.0, -1.0}}}, {{}, {}}));
186 trg.add_node(make_and_check(t, t.report(
""), {{{1, 1.0, -1.0}, {1, 0.0, 0.0}}, {{0, 0.0, 0.0}, {0, 1.0, -1.0}}}, {{}, {}}));
191 auto g{make_and_check(t, t.report(
""), {{{1, 0.0, 0.0}, {1, 0.0, 0.0}, {1, 1.0, -1.0}, {1, 1.0, -1.0}}, {{0, 1.0, -1.0}, {0, 1.0, -1.0}, {0, 0.0, 0.0}, {0, 0.0, 0.0}}}, {{}, {}})};
193 t.report(
"Canonical ordering of weighted edges"),
194 graph_t{{{{1, 0.0, 0.0}, {1, 1.0, -1.0}, {1, 1.0, -1.0}, {1, 0.0, 0.0}},
195 {{0, 1.0, -1.0}, {0, 0.0, 0.0}, {0, 1.0, -1.0}, {0, 0.0, 0.0}}}, {{}, {}}},
204 auto g{make_and_check(t,
206 {{{0, 1.0, -1.0}, {0, 1.0, -1.0}, {1, 0.0, 0.0}, {1, 0.0, 0.0}, {1, 1.0, -1.0}, {1, 1.0, -1.0}},
207 {{0, 1.0, -1.0}, {0, 1.0, -1.0}, {0, 0.0, 0.0}, {0, 0.0, 0.0}}},
210 t.report(
"Canonical ordering of weighted edges"),
211 graph_t{{{{1, 0.0, 0.0}, {0, 1.0, -1.0}, {1, 1.0, -1.0}, {1, 1.0, -1.0}, {1, 0.0, 0.0}, {0, 1.0, -1.0}},
212 {{0, 1.0, -1.0}, {0, 0.0, 0.0}, {0, 1.0, -1.0}, {0, 0.0, 0.0}}}, {{}, {}}},
unsortable_weight_graph_description
Convention: the indices following 'node' - separated by underscores - give the target node of the ass...
Definition: DynamicUndirectedGraphUnsortableWeightTestingUtilities.hpp:18
Definition: DynamicGraph.hpp:303
Definition: DynamicGraph.hpp:360
class template from which all concrete tests should derive.
Definition: FreeTestCore.hpp:144
Exposes elementary check methods, with the option to plug in arbitrary Extenders to compose functiona...
Definition: FreeCheckers.hpp:708
Definition: DynamicUndirectedGraphTestingUtilities.hpp:138
Definition: DynamicUndirectedGraphUnsortableWeightTestingUtilities.hpp:83
Definition: DynamicGraphTestingUtilities.hpp:173
Definition: StateTransitionUtilities.hpp:77