Sequoia
Loading...
Searching...
No Matches
DynamicDirectedGraphWeightedTestingUtilities.hpp
Go to the documentation of this file.
1
2// Copyright Oliver J. Rosten 2023. //
3// Distributed under the GNU GENERAL PUBLIC LICENSE, Version 3.0. //
4// (See accompanying file LICENSE.md or copy at //
5// https://www.gnu.org/licenses/gpl-3.0.en.html) //
7
8#pragma once
9
13
14namespace sequoia::testing
15{
16 namespace directed_graph{
18 enum weighted_graph_description : std::size_t {
19 // x
20 nodew = graph_description::end,
21
22 // /\
23 // \/
24 // x
25 nodew_0,
26
27 // /\
28 // \/
29 // x
30 node_0w,
31
32 // /\ /\
33 // \/ \/
34 // x
35 node_0w_0w,
36
37 // /\ /\
38 // \/ \/
39 // x
40 node_0_0w,
41
42 // /\ /\
43 // \/ \/
44 // x
45 node_0w_0,
46
47 // x x
48 node_nodew,
49
50 // x x
51 nodew_node,
52
53 // x ---> x
54 node_1_nodew,
55
56 // x <--- x
57 nodew_node_0,
58
59 // x ===> x
60 node_1_1w_node,
61
62 // x ===> x
63 node_1w_1_node,
64
65 // x ===> x
66 node_1w_1w_node,
67
68 // --->
69 // x ===> x
70 node_1_1w_1x_node,
71
72 // x ===> x
73 // --->
74 node_1w_1x_1_node,
75
76 // x ===> x
77 // --->
78 node_1x_1w_1_node,
79
80 // />\
81 // \ /
82 // x ===> x
83 // --->
84 node_1_1w_1x_0y_node,
85
86 // />\
87 // \ /
88 // x ===> x
89 // --->
90 node_0y_1x_1w_1_node,
91
92 // 18 loops
93 // />\
94 // \ /
95 // x 18 edges -> x
96 node_0uuu_1uuu_0vvv_1vvv_0www_1www_0xxx_1xxx_0yyy_1yyy_0zzz_1zzz_node,
97
98 // 18 loops
99 // />\
100 // \ /
101 // x 18 edges -> x
102 node_0zzz_1zzz_0yyy_1yyy_0xxx_1xxx_0www_1www_0vvv_1vvv_0uuu_1uuu_node
103 };
104 }
105
106 template
107 <
108 class EdgeWeight,
109 class NodeWeight,
110 class EdgeStorageConfig,
111 class NodeWeightStorage
112 >
114 {
115 public:
117 using edge_t = typename graph_t::edge_init_type;
118 using node_weight_type = typename graph_t::node_weight_type;
119 using edges_equivalent_t = std::initializer_list<std::initializer_list<edge_t>>;
120 using transition_graph = typename transition_checker<graph_t>::transition_graph;
121
122 static void execute_operations(regular_test& t)
123 {
124 auto trg{make_weighted_transition_graph(t)};
125
126 auto checker{
127 [&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) {
128 t.check(equality, {description, no_source_location}, obtained, prediction);
129 if(host != target) t.check_semantics({description, no_source_location}, prediction, parent);
130 }
131 };
132
134 }
135
136 static void check_initialization_exceptions(regular_test& t)
137 {
138 using nodes = std::initializer_list<node_weight_type>;
139
140 t.check_exception_thrown<std::out_of_range>("Zeroth partial index of edge out of range", [](){ return graph_t{{edge_t{1, 1.0}}}; });
141 t.check_exception_thrown<std::out_of_range>("First partial index of edge out of range", [](){ return graph_t{{edge_t{0, 1.0}, edge_t{1, 1.0}}}; });
142 t.check_exception_thrown<std::out_of_range>("First partial index of edge out of range", [](){ return graph_t{{edge_t{0, 1.0}, edge_t{2, 1.0}}, {}}; });
143 t.check_exception_thrown<std::out_of_range>("Zeroth partial index of node 1's edge out of range", [](){ return graph_t{{edge_t{0, 1.0}, edge_t{1, 1.0}}, {edge_t{2, 1.0}}}; });
144
145 t.check_exception_thrown<std::logic_error>("Mismatched edge/node initialization", [](){ return graph_t{{}, nodes{1.0}}; });
146 t.check_exception_thrown<std::logic_error>("Mismatched edge/node initialization", [](){ return graph_t{{{}}, nodes{1.0, 2.0}}; });
147 t.check_exception_thrown<std::logic_error>("Mismatched edge/node initialization", [](){ return graph_t{{{edge_t{0, 1.0}}}, nodes{1.0, 2.0}}; });
148 t.check_exception_thrown<std::logic_error>("Mismatched edge/node initialization", [](){ return graph_t{{{}, {}}, nodes{1.0}}; });
149 t.check_exception_thrown<std::logic_error>("Mismatched edge/node initialization", [](){ return graph_t{{{edge_t{1}}, {edge_t{0}}}, nodes{1.0}}; });
150 }
151
152
153 [[nodiscard]]
154 static graph_t make_and_check(regular_test& t, std::string_view description, edges_equivalent_t edgeInit, std::initializer_list<node_weight_type> nodeInit)
155 {
156 return graph_initialization_checker<graph_t>::make_and_check(t, description, edgeInit, nodeInit);
157 }
158
159 [[nodiscard]]
160 static transition_graph make_weighted_transition_graph(regular_test& t)
161 {
163 using namespace directed_graph;
164
165 auto trg{base_ops::make_transition_graph(t)};
166
167 check_initialization_exceptions(t);
168
169 // 'weighted_graph_description::nodew'
170 trg.add_node(make_and_check(t, t.report(""), {{}}, {1.0}));
171
172 // 'weighted_graph_description::nodew_0'
173 trg.add_node(make_and_check(t, t.report(""), {{{0, 0.0}}}, {1.0}));
174
175 // 'weighted_graph_description::node_0w'
176 trg.add_node(make_and_check(t, t.report(""), {{{0, 1.0}}}, {0.0}));
177
178 // 'weighted_graph_description::node_0w_0w'
179 trg.add_node(make_and_check(t, t.report(""), {{{0, 1.0}, {0, 1.0}}}, {0.0}));
180
181 // 'weighted_graph_description::node_0_0w'
182 trg.add_node(make_and_check(t, t.report(""), {{{0, 0.0}, {0, 1.0}}}, {0.0}));
183
184 // 'weighted_graph_description::node_0w_0'
185 trg.add_node(make_and_check(t, t.report(""), {{{0, 1.0}, {0, 0.0}}}, {0.0}));
186
187 // 'weighted_graph_description::node_nodew'
188 trg.add_node(make_and_check(t, t.report(""), {{}, {}}, {0.0, 1.0}));
189
190 // 'weighted_graph_description::nodew_node'
191 trg.add_node(make_and_check(t, t.report(""), {{}, {}}, {1.0, 0.0}));
192
193 // 'weighted_graph_description::node_1_nodew'
194 trg.add_node(make_and_check(t, t.report(""), {{{1, 0.0}}, {}}, {0.0, 1.0}));
195
196 // 'weighted_graph_description::nodew_node_0'
197 trg.add_node(make_and_check(t, t.report(""), {{}, {{0, 0.0}}}, {1.0, 0.0}));
198
199 // 'weighted_graph_description::node_1_1w_node'
200 trg.add_node(make_and_check(t, t.report(""), {{{1, 0.0}, {1, 1.0}}, {}}, {0.0, 0.0}));
201
202 // 'weighted_graph_description::node_1w_1_node'
203 trg.add_node(make_and_check(t, t.report(""), {{{1, 1.0}, {1, 0.0}}, {}}, {0.0, 0.0}));
204
205 // 'weighted_graph_description::node_1w_1w_node'
206 trg.add_node(make_and_check(t, t.report(""), {{{1, 1.0}, {1, 1.0}}, {}}, {0.0, 0.0}));
207
208 // 'weighted_graph_description::node_1_1w_1x_node'
209 trg.add_node(make_and_check(t, t.report(""), {{{1, 0.0}, {1, 1.0}, {1, 2.0}}, {}}, {0.0, 0.0}));
210
211 // 'weighted_graph_description::node_1w_1x_1_node'
212 trg.add_node(make_and_check(t, t.report(""), {{{1, 1.0}, {1, 2.0}, {1, 0.0}}, {}}, {0.0, 0.0}));
213
214 // 'weighted_graph_description::node_1x_1w_1_node'
215 trg.add_node(make_and_check(t, t.report(""), {{{1, 2.0}, {1, 1.0}, {1, 0.0}}, {}}, {0.0, 0.0}));
216
217 // 'weighted_graph_description::node_1_1w_1x_0y_node'
218 trg.add_node(make_and_check(t, t.report(""), {{{1, 0.0}, {1, 1.0}, {1, 2.0}, {0, 3.0}}, {}}, {0.0, 0.0}));
219
220 // 'weighted_graph_description::node_0y_1x_1w_1_node'
221 trg.add_node(make_and_check(t, t.report(""), {{{0, 3.0}, {1, 2.0}, {1, 1.0}, {1, 0.0}}, {}}, {0.0, 0.0}));
222
223 // 'weighted_graph_description::node_0uuu_1uuu_0vvv_1vvv_0www_1www_0xxx_1xxx_0yyy_1yyy_0zzz_1zzz_node'
224 trg.add_node(make_and_check(t, t.report(""), {{
225 {0, -2.0}, {0, -2.0}, {0, -2.0}, {1, -2.0}, {1, -2.0}, {1, -2.0},
226 {0, -1.0}, {0, -1.0}, {0, -1.0}, {1, -1.0}, {1, -1.0}, {1, -1.0},
227 {0, 0.0}, {0, 0.0}, {0, 0.0}, {1, 0.0}, {1, 0.0}, {1, 0.0},
228 {0, 1.0}, {0, 1.0}, {0, 1.0}, {1, 1.0}, {1, 1.0}, {1, 1.0},
229 {0, 2.0}, {0, 2.0}, {0, 2.0}, {1, 2.0}, {1, 2.0}, {1, 2.0},
230 {0, 3.0}, {0, 3.0}, {0, 3.0}, {1, 3.0}, {1, 3.0}, {1, 3.0}
231 },
232 {}}, {0.0, 0.0}));
233
234 // 'weighted_graph_description::node_0zzz_1zzz_0yyy_1yyy_0xxx_1xxx_0www_1www_0vvv_1vvv_0uuu_1uuu_node'
235 trg.add_node(make_and_check(t, t.report(""), {{
236 {0, 3.0}, {0, 3.0}, {0, 3.0}, {1, 3.0}, {1, 3.0}, {1, 3.0},
237 {0, 2.0}, {0, 2.0}, {0, 2.0}, {1, 2.0}, {1, 2.0}, {1, 2.0},
238 {0, 1.0}, {0, 1.0}, {0, 1.0}, {1, 1.0}, {1, 1.0}, {1, 1.0},
239 {0, 0.0}, {0, 0.0}, {0, 0.0}, {1, 0.0}, {1, 0.0}, {1, 0.0},
240 {0, -1.0}, {0, -1.0}, {0, -1.0}, {1, -1.0}, {1, -1.0}, {1, -1.0},
241 {0, -2.0}, {0, -2.0}, {0, -2.0}, {1, -2.0}, {1, -2.0}, {1, -2.0}
242 },
243 {}}, {0.0, 0.0}));
244
245 // begin 'graph_description::empty'
246
247 trg.join(
248 graph_description::empty,
249 graph_description::empty,
250 t.report(""),
251 [&t](graph_t g) -> graph_t {
252 t.check_exception_thrown<std::out_of_range>("Attempt to set a node weight which does not exist", [&g](){ g.set_node_weight(g.cbegin_node_weights(), 1.0); });
253 return g;
254 }
255 );
256
257 trg.join(
258 graph_description::empty,
259 graph_description::empty,
260 t.report("Attempt to mutate a node weight which does not exist"),
261 [&t](graph_t g) -> graph_t {
262 t.check_exception_thrown<std::out_of_range>("Attempt to mutate a node weight which does not exist", [&g](){ g.mutate_node_weight(g.cbegin_node_weights(), [](double&){}); });
263 return g;
264 }
265 );
266
267 trg.join(
268 graph_description::empty,
269 weighted_graph_description::nodew,
270 t.report("Add weighted node"),
271 [](graph_t g) -> graph_t {
272 g.add_node(1.0);
273 return g;
274 }
275 );
276
277 trg.join(
278 graph_description::empty,
279 weighted_graph_description::nodew,
280 t.report("Insert weighted node"),
281 [](graph_t g) -> graph_t {
282 g.insert_node(0, 1.0);
283 return g;
284 }
285 );
286
287 // end 'graph_description::empty'
288
289 // begin 'graph_description::node'
290
291 trg.join(
292 graph_description::node,
293 graph_description::node,
294 t.report(""),
295 [&t](graph_t g) -> graph_t {
296 t.check_exception_thrown<std::out_of_range>("Attempt to set a node weight which does not exist", [&g](){ g.set_node_weight(g.cend_node_weights(), 1.0); });
297 return g;
298 }
299 );
300
301 trg.join(
302 graph_description::node,
303 graph_description::node,
304 t.report("Attempt to mutate a node weight which does not exist"),
305 [&t](graph_t g) -> graph_t {
306 t.check_exception_thrown<std::out_of_range>("Attempt to mutate a node weight which does not exist", [&g](){ g.mutate_node_weight(g.cend_node_weights(), [](double&){}); });
307 return g;
308 }
309 );
310
311 trg.join(
312 graph_description::node,
313 weighted_graph_description::nodew,
314 t.report("Change node weight"),
315 [](graph_t g) -> graph_t {
316 g.set_node_weight(g.cbegin_node_weights(), 1.0);
317 return g;
318 }
319 );
320
321 trg.join(
322 graph_description::node,
323 weighted_graph_description::nodew,
324 t.report("Mutate node weight"),
325 [](graph_t g) -> graph_t {
326 g.mutate_node_weight(g.cbegin_node_weights(), [](double& x) { x += 1.0; });
327 return g;
328 }
329 );
330
331
332 trg.join(
333 graph_description::node,
334 weighted_graph_description::nodew,
335 t.report("Change node weight via iterator"),
336 [](graph_t g) -> graph_t {
337 *g.begin_node_weights() = 1.0;
338 return g;
339 }
340 );
341
342 trg.join(
343 graph_description::node,
344 weighted_graph_description::nodew_node,
345 t.report("Insert weighted node"),
346 [](graph_t g) -> graph_t {
347 g.insert_node(0, 1.0);
348 return g;
349 }
350 );
351
352 // end 'graph_description::node'
353
354 // begin 'graph_description::node_0'
355
356 trg.join(
357 graph_description::node_0,
358 weighted_graph_description::node_0w,
359 t.report("Set edge weight"),
360 [](graph_t g) -> graph_t {
361 g.set_edge_weight(g.cbegin_edges(0), 1.0);
362 return g;
363 }
364 );
365
366 trg.join(
367 graph_description::node_0,
368 weighted_graph_description::node_0w,
369 t.report("Mutate edge weight"),
370 [](graph_t g) -> graph_t {
371 g.mutate_edge_weight(g.cbegin_edges(0), [](double& x){ x += 1.0; });
372 return g;
373 }
374 );
375
376 trg.join(
377 graph_description::node_0,
378 weighted_graph_description::node_0w,
379 t.report("Mutate edge weight"),
380 [](graph_t g) -> graph_t {
381 *g.begin_edge_weights(0) += 1.0;;
382 return g;
383 }
384 );
385
386 trg.join(
387 graph_description::node_0,
388 weighted_graph_description::node_0w,
389 t.report("Mutate edge weight"),
390 [](graph_t g) -> graph_t {
391 *g.rbegin_edge_weights(0) += 1.0;;
392 return g;
393 }
394 );
395
396 trg.join(
397 graph_description::node_0,
398 weighted_graph_description::node_0w,
399 t.report("Mutate edge weight"),
400 [](graph_t g) -> graph_t {
401 *g.edge_weights(0).begin() += 1.0;;
402 return g;
403 }
404 );
405
406 trg.join(
407 graph_description::node_0,
408 weighted_graph_description::node_0_0w,
409 t.report("Join {0,0}"),
410 [](graph_t g) -> graph_t {
411 g.join(0, 0, 1.0);
412 return g;
413 }
414 );
415
416 // end 'graph_description::node_0'
417
418 // begin 'graph_description::node_0_0'
419
420 trg.join(
421 graph_description::node_0_0,
422 weighted_graph_description::node_0w_0,
423 t.report("Set zeroth edge weight"),
424 [](graph_t g) -> graph_t {
425 g.set_edge_weight(g.cbegin_edges(0), 1.0);
426 return g;
427 }
428 );
429
430 trg.join(
431 graph_description::node_0_0,
432 weighted_graph_description::node_0_0w,
433 t.report("Set first edge weight"),
434 [](graph_t g) -> graph_t {
435 g.set_edge_weight(++g.cbegin_edges(0), 1.0);
436 return g;
437 }
438 );
439
440 // end 'graph_description::node_0_0'
441
442 // begin 'graph_description::node_1_1_node'
443
444 trg.join(
445 graph_description::node_1_1_node,
446 weighted_graph_description::node_1_1w_node,
447 t.report("Set edge weight"),
448 [](graph_t g) -> graph_t {
449 g.set_edge_weight(++g.cbegin_edges(0), 1.0);
450 return g;
451 }
452 );
453
454 trg.join(
455 graph_description::node_1_1_node,
456 weighted_graph_description::node_1_1w_node,
457 t.report("Mutate edge weight"),
458 [](graph_t g) -> graph_t {
459 g.mutate_edge_weight(++g.cbegin_edges(0), [](double& x) { x += 1.0; });
460 return g;
461 }
462 );
463
464 trg.join(
465 graph_description::node_1_1_node,
466 weighted_graph_description::node_1w_1_node,
467 t.report("Set edge weight"),
468 [](graph_t g) -> graph_t {
469 g.set_edge_weight(g.cbegin_edges(0), 1.0);
470 return g;
471 }
472 );
473
474 trg.join(
475 graph_description::node_1_1_node,
476 weighted_graph_description::node_1w_1_node,
477 t.report("Mutate edge weight"),
478 [](graph_t g) -> graph_t {
479 g.mutate_edge_weight(g.cbegin_edges(0), [](double& x) { x += 1.0; });
480 return g;
481 }
482 );
483
484 // end 'graph_description::node_1_1_node'
485
486 //======================================= joins from new nodes =======================================//
487
488 // begin 'weighted_graph_description::node_0_0w'
489
490 trg.join(
491 weighted_graph_description::node_0_0w,
492 weighted_graph_description::node_0w_0,
493 t.report("Swap edges"),
494 [](graph_t g) -> graph_t {
495 g.swap_edges(0, 0, 1);
496 return g;
497 }
498 );
499
500 trg.join(
501 weighted_graph_description::node_0_0w,
502 weighted_graph_description::node_0w_0,
503 t.report("Swap edges"),
504 [](graph_t g) -> graph_t {
505 g.swap_edges(0, 1, 0);
506 return g;
507 }
508 );
509
510 trg.join(
511 weighted_graph_description::node_0_0w,
512 weighted_graph_description::node_0w_0,
513 t.report("Sort edges"),
514 [](graph_t g) -> graph_t {
515 g.sort_edges(g.cbegin_edges(0), g.cend_edges(0), [](const auto& lhs, const auto& rhs) { return lhs.weight() > rhs.weight(); });
516 return g;
517 }
518 );
519
520 // end 'weighted_graph_description::node_0_0w'
521
522 // begin 'weighted_graph_description::node_0w_0'
523
524 trg.join(
525 weighted_graph_description::node_0w_0,
526 weighted_graph_description::node_0_0w,
527 t.report("Swap edges"),
528 [](graph_t g) -> graph_t {
529 g.swap_edges(0, 0, 1);
530 return g;
531 }
532 );
533
534 trg.join(
535 weighted_graph_description::node_0w_0,
536 weighted_graph_description::node_0_0w,
537 t.report("Swap edges"),
538 [](graph_t g) -> graph_t {
539 g.swap_edges(0, 1, 0);
540 return g;
541 }
542 );
543
544 trg.join(
545 weighted_graph_description::node_0w_0,
546 weighted_graph_description::node_0_0w,
547 t.report("Sort edges"),
548 [](graph_t g) -> graph_t {
549 g.sort_edges(g.cbegin_edges(0), g.cend_edges(0), [](const auto& lhs, const auto& rhs) { return lhs.weight() < rhs.weight(); });
550 return g;
551 }
552 );
553
554 // end 'weighted_graph_description::node_0w_0'
555
556 // begin 'weighted_graph_description::node_nodew'
557
558 trg.join(
559 weighted_graph_description::node_nodew,
560 weighted_graph_description::nodew_node,
561 t.report("Swap nodes"),
562 [](graph_t g) -> graph_t {
563 g.swap_nodes(0, 1);
564 return g;
565 }
566 );
567
568 // end 'weighted_graph_description::node_nodew'
569
570 // begin 'weighted_graph_description::nodew_node'
571
572 trg.join(
573 weighted_graph_description::nodew_node,
574 weighted_graph_description::node_nodew,
575 t.report("Swap nodes"),
576 [](graph_t g) -> graph_t {
577 g.swap_nodes(1, 0);
578 return g;
579 }
580 );
581
582 // end 'weighted_graph_description::nodew_node'
583
584 // begin 'weighted_graph_description::node_1_nodew'
585
586 trg.join(
587 weighted_graph_description::node_1_nodew,
588 weighted_graph_description::nodew_node_0,
589 t.report("Swap nodes"),
590 [](graph_t g) -> graph_t {
591 g.swap_nodes(0, 1);
592 return g;
593 }
594 );
595
596 // end 'weighted_graph_description::node_1_nodew'
597
598 // begin 'weighted_graph_description::nodew_node_0'
599
600 trg.join(
601 weighted_graph_description::nodew_node_0,
602 weighted_graph_description::node_1_nodew,
603 t.report("Swap nodes"),
604 [](graph_t g) -> graph_t {
605 g.swap_nodes(1, 0);
606 return g;
607 }
608 );
609
610 // end 'weighted_graph_description::nodew_node_0'
611
612 // begin 'weighted_graph_description::node_1_1w_node'
613
614 trg.join(
615 weighted_graph_description::node_1_1w_node,
616 weighted_graph_description::node_1w_1w_node,
617 t.report("Set edge weight"),
618 [](graph_t g) -> graph_t {
619 g.set_edge_weight(g.cbegin_edges(0), 1.0);
620 return g;
621 }
622 );
623
624 trg.join(
625 weighted_graph_description::node_1_1w_node,
626 weighted_graph_description::node_1w_1_node,
627 t.report("Swap edges"),
628 [](graph_t g) -> graph_t {
629 g.swap_edges(0, 0, 1);
630 return g;
631 }
632 );
633
634 trg.join(
635 weighted_graph_description::node_1_1w_node,
636 weighted_graph_description::node_1w_1_node,
637 t.report("Sort edges"),
638 [](graph_t g) -> graph_t {
639 g.sort_edges(g.cbegin_edges(0), g.cend_edges(0), [](const auto& lhs, const auto& rhs) { return lhs.weight() > rhs.weight(); });
640 return g;
641 }
642 );
643
644 // end 'weighted_graph_description::node_1_1w_node'
645
646 // begin 'weighted_graph_description::node_1w_1_node'
647
648 trg.join(
649 weighted_graph_description::node_1w_1_node,
650 weighted_graph_description::node_1w_1w_node,
651 t.report("Set edge weight"),
652 [](graph_t g) -> graph_t {
653 g.set_edge_weight(++g.cbegin_edges(0), 1.0);
654 return g;
655 }
656 );
657
658 trg.join(
659 weighted_graph_description::node_1w_1_node,
660 weighted_graph_description::node_1_1w_node,
661 t.report("Swap edges"),
662 [](graph_t g) -> graph_t {
663 g.swap_edges(0, 0, 1);
664 return g;
665 }
666 );
667
668 trg.join(
669 weighted_graph_description::node_1w_1_node,
670 weighted_graph_description::node_1_1w_node,
671 t.report("Sort edges"),
672 [](graph_t g) -> graph_t {
673 g.sort_edges(g.cbegin_edges(0), g.cend_edges(0), [](const auto& lhs, const auto& rhs) { return lhs.weight() < rhs.weight(); });
674 return g;
675 }
676 );
677
678 // end 'weighted_graph_description::node_1w_1_node'
679
680 // begin 'weighted_graph_description::node_1w_1w_node'
681
682 trg.join(
683 weighted_graph_description::node_1w_1w_node,
684 weighted_graph_description::node_1_1w_node,
685 t.report("Set edge weight"),
686 [](graph_t g) -> graph_t {
687 g.set_edge_weight(g.cbegin_edges(0), 0.0);
688 return g;
689 }
690 );
691
692 trg.join(
693 weighted_graph_description::node_1w_1w_node,
694 weighted_graph_description::node_1_1w_node,
695 t.report("Mutate edge weight"),
696 [](graph_t g) -> graph_t {
697 g.mutate_edge_weight(g.cbegin_edges(0), [](double& x){ x -= 1.0; });
698 return g;
699 }
700 );
701
702 trg.join(
703 weighted_graph_description::node_1w_1w_node,
704 weighted_graph_description::node_1w_1_node,
705 t.report("Set edge weight"),
706 [](graph_t g) -> graph_t {
707 g.set_edge_weight(++g.cbegin_edges(0), 0.0);
708 return g;
709 }
710 );
711
712 trg.join(
713 weighted_graph_description::node_1w_1w_node,
714 weighted_graph_description::node_1w_1_node,
715 t.report("Mutate edge weight"),
716 [](graph_t g) -> graph_t {
717 g.mutate_edge_weight(++g.cbegin_edges(0), [](double& x){ x -= 1.0; });
718 return g;
719 }
720 );
721
722 // end 'weighted_graph_description::node_1w_1w_node'
723
724 // begin 'weighted_graph_description::node_1_1w_1x_node'
725
726 trg.join(
727 weighted_graph_description::node_1_1w_1x_node,
728 weighted_graph_description::node_1_1w_1x_0y_node,
729 t.report("Join {0,0}"),
730 [](graph_t g) -> graph_t {
731 g.join(0, 0, 3.0);
732 return g;
733 }
734 );
735
736 trg.join(
737 weighted_graph_description::node_1_1w_1x_node,
738 weighted_graph_description::node_1w_1x_1_node,
739 t.report("Set multiple edge weights"),
740 [](graph_t g) -> graph_t {
741 g.set_edge_weight(g.cbegin_edges(0), 1.0);
742 g.set_edge_weight(g.cbegin_edges(0) + 1, 2.0);
743 g.set_edge_weight(g.cbegin_edges(0) + 2 , 0.0);
744 return g;
745 }
746 );
747
748 trg.join(
749 weighted_graph_description::node_1_1w_1x_node,
750 weighted_graph_description::node_1w_1x_1_node,
751 t.report("Mutate mutliple edge weights"),
752 [](graph_t g) -> graph_t {
753 g.mutate_edge_weight(g.cbegin_edges(0), [](double& x){ x += 1.0; });
754 g.mutate_edge_weight(g.cbegin_edges(0) + 1, [](double& x){ x += 1.0; });
755 g.mutate_edge_weight(g.cbegin_edges(0) + 2, [](double& x){ x -= 2.0; });
756 return g;
757 }
758 );
759
760 // end 'weighted_graph_description::node_1_1w_1x_node'
761
762 // begin 'weighted_graph_description::node_1w_1x_1_node'
763
764 trg.join(
765 weighted_graph_description::node_1w_1x_1_node,
766 weighted_graph_description::node_1w_1_node,
767 t.report("Remove {0,1}"),
768 [](graph_t g) -> graph_t {
769 g.erase_edge(++g.cbegin_edges(0));
770 return g;
771 }
772 );
773
774 trg.join(
775 weighted_graph_description::node_1w_1x_1_node,
776 weighted_graph_description::node_1_1w_1x_node,
777 t.report("Sort edges"),
778 [](graph_t g) -> graph_t {
779 g.sort_edges(g.cbegin_edges(0), g.cend_edges(0), [](const auto& lhs, const auto& rhs) { return lhs.weight() < rhs.weight(); });
780 return g;
781 }
782 );
783
784 // end 'weighted_graph_description::node_1w_1x_1_node'
785
786 // begin 'weighted_graph_description::node_1x_1w_1_node'
787
788 trg.join(
789 weighted_graph_description::node_1x_1w_1_node,
790 weighted_graph_description::node_1w_1x_1_node,
791 t.report("Swap edges"),
792 [](graph_t g) -> graph_t {
793 g.swap_edges(0, 1, 0);
794 return g;
795 }
796 );
797
798 trg.join(
799 weighted_graph_description::node_1x_1w_1_node,
800 weighted_graph_description::node_1_1w_1x_node,
801 t.report("Sort edges"),
802 [](graph_t g) -> graph_t {
803 g.sort_edges(g.cbegin_edges(0), g.cend_edges(0), [](const auto& lhs, const auto& rhs) { return lhs.weight() < rhs.weight(); });
804 return g;
805 }
806 );
807
808 // end 'weighted_graph_description::node_1x_1w_1_node'
809
810 // begin 'weighted_graph_description::node_1_1w_1x_0y_node'
811
812 trg.join(
813 weighted_graph_description::node_1_1w_1x_0y_node,
814 weighted_graph_description::node_0y_1x_1w_1_node,
815 t.report("Sort edges"),
816 [](graph_t g) -> graph_t {
817 g.sort_edges(g.cbegin_edges(0), g.cend_edges(0), [](const auto& lhs, const auto& rhs) { return lhs.weight() > rhs.weight(); });
818 return g;
819 }
820 );
821
822 // end 'weighted_graph_description::node_1_1w_1x_0y_node'
823
824 // begin 'weighted_graph_description::node_0y_1x_1w_1_node'
825
826 trg.join(
827 weighted_graph_description::node_0y_1x_1w_1_node,
828 weighted_graph_description::node_1x_1w_1_node,
829 t.report("Remove {0,0}"),
830 [](graph_t g) -> graph_t {
831 g.erase_edge(g.cbegin_edges(0));
832 return g;
833 }
834 );
835
836 trg.join(
837 weighted_graph_description::node_0y_1x_1w_1_node,
838 weighted_graph_description::node_1_1w_1x_0y_node,
839 t.report("Sort edges"),
840 [](graph_t g) -> graph_t {
841 g.sort_edges(g.cbegin_edges(0), g.cend_edges(0), [](const auto& lhs, const auto& rhs) { return lhs.weight() < rhs.weight(); });
842 return g;
843 }
844 );
845
846 // end'weighted_graph_description::node_0y_1x_1w_1_node'
847
848 // begin 'weighted_graph_description::node_0uuu_1uuu_0vvv_1vvv_0www_1www_0xxx_1xxx_0yyy_1yyy_0zzz_1zzz_node'
849
850 trg.join(
851 weighted_graph_description::node_0uuu_1uuu_0vvv_1vvv_0www_1www_0xxx_1xxx_0yyy_1yyy_0zzz_1zzz_node,
852 weighted_graph_description::node_0zzz_1zzz_0yyy_1yyy_0xxx_1xxx_0www_1www_0vvv_1vvv_0uuu_1uuu_node,
853 t.report("Sort edges"),
854 [](graph_t g) -> graph_t {
855 g.stable_sort_edges(g.cedges(0), std::ranges::greater{}, [](const auto& e) { return e.weight(); });
856 return g;
857 }
858 );
859
860 // end'weighted_graph_description::node_0uuu_1uuu_0vvv_1vvv_0www_1www_0xxx_1xxx_0yyy_1yyy_0zzz_1zzz_node'
861
862 // begin 'weighted_graph_description::node_0zzz_1zzz_0yyy_1yyy_0xxx_1xxx_0www_1www_0vvv_1vvv_0uuu_1uuu_node'
863
864 trg.join(
865 weighted_graph_description::node_0zzz_1zzz_0yyy_1yyy_0xxx_1xxx_0www_1www_0vvv_1vvv_0uuu_1uuu_node,
866 weighted_graph_description::node_0uuu_1uuu_0vvv_1vvv_0www_1www_0xxx_1xxx_0yyy_1yyy_0zzz_1zzz_node,
867 t.report("Sort edges"),
868 [](graph_t g) -> graph_t {
869 g.stable_sort_edges(g.cbegin_edges(0), g.cend_edges(0), [](const auto& lhs, const auto& rhs) { return lhs.weight() < rhs.weight(); });
870 return g;
871 }
872 );
873
874 // end'weighted_graph_description::node_0zzz_1zzz_0yyy_1yyy_0xxx_1xxx_0www_1www_0vvv_1vvv_0uuu_1uuu_node'
875
876 return trg;
877 }
878 };
879
880
881}
weighted_graph_description
Convention: the indices following 'node' - separated by underscores - give the target node of the ass...
Definition: DynamicDirectedGraphWeightedTestingUtilities.hpp:18
Definition: DynamicGraph.hpp:303
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: DynamicDirectedGraphTestingUtilities.hpp:172
Definition: DynamicDirectedGraphWeightedTestingUtilities.hpp:114
Definition: DynamicGraphTestingUtilities.hpp:173
Definition: StateTransitionUtilities.hpp:77