Sequoia
Loading...
Searching...
No Matches
DynamicUndirectedEmbeddedGraphWeightedTestingUtilities.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 undirected_embedded_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 // /-\/-\
48 // / /\ \
49 // \ / \ /
50 // x
51 node_0w_0_interleaved,
52
53 // /-\/-\
54 // / /\ \
55 // \ / \ /
56 // x
57 node_0_0w_interleaved,
58
59 // /-\/-\
60 // / /\ \
61 // \ / \ /
62 // x
63 node_0w_0w_interleaved,
64
65 // x x
66 node_nodew,
67
68 // x x
69 nodew_node,
70
71 // x ---- x
72 node_1_nodew_0,
73
74 // x ---- x
75 nodew_1_node_0,
76
77 // x ==== x
78 node_1_1w_node_0_0w,
79
80 // x ==== x
81 node_1w_1w_node_0w_0w,
82
83 // x ---- x
84 // ----
85 node_1w_1_node_0_0w,
86
87 // x ---- x
88 // ----
89 node_1_1w_node_0w_0,
90
91 // ----
92 // x ==== x
93 node_1_1w_1x_node_0_0w_0x,
94
95 // /-\
96 // \ /
97 // x ==== x
98 // ----
99 node_0y_1_1w_1x_node_0_0w_0x,
100 };
101 }
102
103 template
104 <
105 class EdgeWeight,
106 class NodeWeight,
107 class EdgeStorageConfig,
108 class NodeWeightStorage
109 >
111 {
112 public:
114 using edge_t = typename graph_t::edge_init_type;
115 using node_weight_type = typename graph_t::node_weight_type;
116 using edges_equivalent_t = std::initializer_list<std::initializer_list<edge_t>>;
117 using transition_graph = typename transition_checker<graph_t>::transition_graph;
118
119 static void execute_operations(regular_test& t)
120 {
121 auto trg{make_weighted_transition_graph(t)};
122
123 auto checker{
124 [&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) {
125 t.check(equality, {description, no_source_location}, obtained, prediction);
126 if(host != target) t.check_semantics({description, no_source_location}, prediction, parent);
127 }
128 };
129
131 }
132
133 [[nodiscard]]
134 static graph_t make_and_check(regular_test& t, std::string_view description, edges_equivalent_t edgeInit, std::initializer_list<node_weight_type> nodeInit)
135 {
136 return graph_initialization_checker<graph_t>::make_and_check(t, description, edgeInit, nodeInit);
137 }
138
139 static void check_initialization_exceptions(regular_test& t)
140 {
141 using nodes = std::initializer_list<node_weight_type>;
142
143 // One node
144 t.check_exception_thrown<std::logic_error>("Mismatched weights", [](){ return graph_t{{{0, 1, 1.0}, {0, 0, 0.0}}}; });
145
146 // Two nodes
147 t.check_exception_thrown<std::logic_error>("IMismatched weights", [](){ return graph_t{{{1, 0, 1.0}}, {{0, 0, 2.0}}}; });
148
149 t.check_exception_thrown<std::logic_error>("Mismatched edge/node initialization", [](){ return graph_t{{}, nodes{1.0}}; });
150 t.check_exception_thrown<std::logic_error>("Mismatched edge/node initialization", [](){ return graph_t{{{}}, nodes{1.0, 2.0}}; });
151 t.check_exception_thrown<std::logic_error>("Mismatched edge/node initialization", [](){ return graph_t{{{edge_t{0, 1, 1.0}, edge_t{0, 0, 1.0}}}, nodes{1.0, 2.0}}; });
152 t.check_exception_thrown<std::logic_error>("Mismatched edge/node initialization", [](){ return graph_t{{{}, {}}, nodes{1.0}}; });
153 t.check_exception_thrown<std::logic_error>("Mismatched edge/node initialization", [](){ return graph_t{{{edge_t{1, 0}}, {edge_t{0, 0}}}, nodes{1.0}}; });
154 }
155
156
157 [[nodiscard]]
158 static transition_graph make_weighted_transition_graph(regular_test& t)
159 {
161 using namespace undirected_embedded_graph;
162
163 auto trg{base_ops::make_transition_graph(t)};
164
165 check_initialization_exceptions(t);
166
167 // 'weighted_graph_description::nodew'
168 trg.add_node(make_and_check(t, t.report(""), {{}}, {1.0}));
169
170 // 'weighted_graph_description::nodew_0'
171 trg.add_node(make_and_check(t, t.report(""), {{{0, 1, 0.0}, {0, 0, 0.0}}}, {1.0}));
172
173 // 'weighted_graph_description::node_0w'
174 trg.add_node(make_and_check(t, t.report(""), {{{0, 1, 1.0}, {0, 0, 1.0}}}, {0.0}));
175
176 // 'weighted_graph_description::node_0w_0w'
177 trg.add_node(make_and_check(t, t.report(""), {{{0, 1, 1.0}, {0, 0, 1.0}, {0, 3, 1.0}, {0, 2, 1.0}}}, {0.0}));
178
179 // 'weighted_graph_description::node_0_0w'
180 trg.add_node(make_and_check(t, t.report(""), {{{0, 1, 0.0}, {0, 0, 0.0}, {0, 3, 1.0}, {0, 2, 1.0}}}, {0.0}));
181
182 // 'weighted_graph_description::node_0w_0'
183 trg.add_node(make_and_check(t, t.report(""), {{{0, 1, 1.0}, {0, 0, 1.0}, {0, 3, 0.0}, {0, 2, 0.0}}}, {0.0}));
184
185 // 'weighted_graph_description::node_0w_0_interleaved'
186 trg.add_node(make_and_check(t, t.report(""), {{{0, 2, 1.0}, {0, 3, 0.0}, {0, 0, 1.0}, {0, 1, 0.0}}}, {0.0}));
187
188 // 'weighted_graph_description::node_0_0w_interleaved'
189 trg.add_node(make_and_check(t, t.report(""), {{{0, 2, 0.0}, {0, 3, 1.0}, {0, 0, 0.0}, {0, 1, 1.0}}}, {0.0}));
190
191 // 'weighted_graph_description::node_0w_0w_interleaved'
192 trg.add_node(make_and_check(t, t.report(""), {{{0, 2, 1.0}, {0, 3, 1.0}, {0, 0, 1.0}, {0, 1, 1.0}}}, {0.0}));
193
194 // 'weighted_graph_description::node_nodew'
195 trg.add_node(make_and_check(t, t.report(""), {{}, {}}, {0.0, 1.0}));
196
197 // 'weighted_graph_description::nodew_node'
198 trg.add_node(make_and_check(t, t.report(""), {{}, {}}, {1.0, 0.0}));
199
200 // 'weighted_graph_description::node_1_nodew_0'
201 trg.add_node(make_and_check(t, t.report(""), {{{1, 0, 0.0}}, {{0, 0, 0.0}}}, {0.0, 1.0}));
202
203 // 'weighted_graph_description::nodew_1_node_0'
204 trg.add_node(make_and_check(t, t.report(""), {{{1, 0, 0.0}}, {{0, 0, 0.0}}}, {1.0, 0.0}));
205
206 // 'weighted_graph_description::node_1_1w_node_0_0w'
207 trg.add_node(make_and_check(t, t.report(""), {{{1, 0, 0.0}, {1, 1, 1.0}}, {{0, 0, 0.0}, {0, 1, 1.0}}}, {0.0, 0.0}));
208
209 // 'weighted_graph_description::node_1w_1w_node_0w_0w'
210 trg.add_node(make_and_check(t, t.report(""), {{{1, 0, 1.0}, {1, 1, 1.0}}, {{0, 0, 1.0}, {0, 1, 1.0}}}, {0.0, 0.0}));
211
212 // 'weighted_graph_description::node_1w_1_node_0_0w'
213 trg.add_node(make_and_check(t, t.report(""), {{{1, 1, 1.0}, {1, 0, 0.0}}, {{0, 1, 0.0}, {0, 0, 1.0}}}, {0.0, 0.0}));
214
215 // 'weighted_graph_description::node_1_1w_node_0w_0'
216 trg.add_node(make_and_check(t, t.report(""), {{{1, 1, 0.0}, {1, 0, 1.0}}, {{0, 1, 1.0}, {0, 0, 0.0}}}, {0.0, 0.0}));
217
218 // 'weighted_graph_description::node_1_1w_1x_node_0_0w_0x'
219 trg.add_node(make_and_check(t, t.report(""), {{{1, 0, 0.0}, {1, 1, 1.0}, {1, 2, 2.0}}, {{0, 0, 0.0}, {0, 1, 1.0}, {0, 2, 2.0}}}, {0.0, 0.0}));
220
221 // 'weighted_graph_description::node_0y_1_1w_1x_node_0_0w_0x'
222 trg.add_node(make_and_check(t, t.report(""), {{{0, 1, 3.0}, {0, 0, 3.0}, {1, 0, 0.0}, {1, 1, 1.0}, {1, 2, 2.0}}, {{0, 2, 0.0}, {0, 3, 1.0}, {0, 4, 2.0}}}, {0.0, 0.0}));
223
224 // begin 'graph_description::empty'
225
226 trg.join(
227 graph_description::empty,
228 graph_description::empty,
229 t.report(""),
230 [&t](graph_t g) -> graph_t {
231 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); });
232 return g;
233 }
234 );
235
236 trg.join(
237 graph_description::empty,
238 graph_description::empty,
239 t.report("Attempt to mutate a node weight which does not exist"),
240 [&t](graph_t g) -> graph_t {
241 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&){}); });
242 return g;
243 }
244 );
245
246 trg.join(
247 graph_description::empty,
248 weighted_graph_description::nodew,
249 t.report("Add weighted node"),
250 [](graph_t g) -> graph_t {
251 g.add_node(1.0);
252 return g;
253 }
254 );
255
256 trg.join(
257 graph_description::empty,
258 weighted_graph_description::nodew,
259 t.report("Insert weighted node"),
260 [](graph_t g) -> graph_t {
261 g.insert_node(0, 1.0);
262 return g;
263 }
264 );
265
266 // end 'graph_description::empty'
267
268 // begin 'graph_description::node'
269
270 trg.join(
271 graph_description::node,
272 graph_description::node,
273 t.report(""),
274 [&t](graph_t g) -> graph_t {
275 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); });
276 return g;
277 }
278 );
279
280 trg.join(
281 graph_description::node,
282 graph_description::node,
283 t.report("Attempt to mutate a node weight which does not exist"),
284 [&t](graph_t g) -> graph_t {
285 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&){}); });
286 return g;
287 }
288 );
289
290 trg.join(
291 graph_description::node,
292 weighted_graph_description::nodew,
293 t.report("Change node weight"),
294 [](graph_t g) -> graph_t {
295 g.set_node_weight(g.cbegin_node_weights(), 1.0);
296 return g;
297 }
298 );
299
300 trg.join(
301 graph_description::node,
302 weighted_graph_description::nodew,
303 t.report("Mutate node weight"),
304 [](graph_t g) -> graph_t {
305 g.mutate_node_weight(g.cbegin_node_weights(), [](double& x) { x += 1.0; });
306 return g;
307 }
308 );
309
310 trg.join(
311 graph_description::node,
312 weighted_graph_description::nodew_node,
313 t.report("Insert weighted node"),
314 [](graph_t g) -> graph_t {
315 g.insert_node(0, 1.0);
316 return g;
317 }
318 );
319
320 trg.join(
321 graph_description::node,
322 weighted_graph_description::node_0w,
323 t.report("Join {0,0}"),
324 [](graph_t g) -> graph_t {
325 g.join(0, 0, 1.0);
326 return g;
327 }
328 );
329
330 // end 'graph_description::node'
331
332 // begin 'graph_description::node_0'
333
334 trg.join(
335 graph_description::node_0,
336 weighted_graph_description::node_0w,
337 t.report("Set edge weight"),
338 [](graph_t g) -> graph_t {
339 g.set_edge_weight(g.cbegin_edges(0), 1.0);
340 return g;
341 }
342 );
343
344 trg.join(
345 graph_description::node_0,
346 weighted_graph_description::node_0w,
347 t.report("Set edge weight via second insertion"),
348 [](graph_t g) -> graph_t {
349 g.set_edge_weight(++g.cbegin_edges(0), 1.0);
350 return g;
351 }
352 );
353
354 trg.join(
355 graph_description::node_0,
356 weighted_graph_description::node_0w,
357 t.report("Mutate edge weight"),
358 [](graph_t g) -> graph_t {
359 g.mutate_edge_weight(g.cbegin_edges(0), [](double& x){ x += 1.0; });
360 return g;
361 }
362 );
363
364 trg.join(
365 graph_description::node_0,
366 weighted_graph_description::node_0w,
367 t.report("Mutate edge weight via second insertion"),
368 [](graph_t g) -> graph_t {
369 g.mutate_edge_weight(++g.cbegin_edges(0), [](double& x){ x += 1.0; });
370 return g;
371 }
372 );
373
374 trg.join(
375 graph_description::node_0,
376 weighted_graph_description::node_0_0w,
377 t.report("Join {0,0}"),
378 [](graph_t g) -> graph_t {
379 g.join(0, 0, 1.0);
380 return g;
381 }
382 );
383
384 trg.join(
385 graph_description::node_0,
386 weighted_graph_description::node_0w_0_interleaved,
387 t.report("Insert weighted join {0,0}"),
388 [](graph_t g) -> graph_t {
389 g.insert_join(g.cbegin_edges(0), 2, 1.0);
390 return g;
391 }
392 );
393
394 trg.join(
395 graph_description::node_0,
396 weighted_graph_description::node_0_0w_interleaved,
397 t.report("Insert weighted join {0,0}"),
398 [](graph_t g) -> graph_t {
399 g.insert_join(g.cbegin_edges(0)+1, 3, 1.0);
400 return g;
401 }
402 );
403
404 // end 'graph_description::node_0'
405
406 // begin 'graph_description::node_0_0'
407
408 trg.join(
409 graph_description::node_0_0,
410 weighted_graph_description::node_0w_0,
411 t.report("Set edge weight via zeroth partial weight"),
412 [](graph_t g) -> graph_t {
413 g.set_edge_weight(g.cbegin_edges(0), 1.0);
414 return g;
415 }
416 );
417
418 trg.join(
419 graph_description::node_0_0,
420 weighted_graph_description::node_0w_0,
421 t.report("Set edge weight via first partial weight"),
422 [](graph_t g) -> graph_t {
423 g.set_edge_weight(g.cbegin_edges(0) + 1, 1.0);
424 return g;
425 }
426 );
427
428 trg.join(
429 graph_description::node_0_0,
430 weighted_graph_description::node_0_0w,
431 t.report("Set edge weight via second partial weight"),
432 [](graph_t g) -> graph_t {
433 g.set_edge_weight(g.cbegin_edges(0) + 2, 1.0);
434 return g;
435 }
436 );
437
438 trg.join(
439 graph_description::node_0_0,
440 weighted_graph_description::node_0_0w,
441 t.report("Set edge weight via third partial weight"),
442 [](graph_t g) -> graph_t {
443 g.set_edge_weight(g.cbegin_edges(0) + 3, 1.0);
444 return g;
445 }
446 );
447
448 trg.join(
449 graph_description::node_0_0,
450 weighted_graph_description::node_0w_0,
451 t.report("Mutate edge weight via zeroth partial weight"),
452 [](graph_t g) -> graph_t {
453 g.mutate_edge_weight(g.cbegin_edges(0), [](double& x) { x += 1.0; });
454 return g;
455 }
456 );
457
458 trg.join(
459 graph_description::node_0_0,
460 weighted_graph_description::node_0w_0,
461 t.report("Mutate edge weight via first partial weight"),
462 [](graph_t g) -> graph_t {
463 g.mutate_edge_weight(g.cbegin_edges(0)+1, [](double& x) { x += 1.0; });
464 return g;
465 }
466 );
467
468 trg.join(
469 graph_description::node_0_0,
470 weighted_graph_description::node_0_0w,
471 t.report("Mutate edge weight via second partial weight"),
472 [](graph_t g) -> graph_t {
473 g.mutate_edge_weight(g.cbegin_edges(0)+2, [](double& x) { x += 1.0; });
474 return g;
475 }
476 );
477
478 trg.join(
479 graph_description::node_0_0,
480 weighted_graph_description::node_0_0w,
481 t.report("Mutate edge weight via third partial weight"),
482 [](graph_t g) -> graph_t {
483 g.mutate_edge_weight(g.cbegin_edges(0)+3, [](double& x) { x += 1.0; });
484 return g;
485 }
486 );
487
488 // end 'graph_description::node_0_0'
489
490 // begin 'graph_description::node_0_0_interleaved'
491
492 trg.join(
493 graph_description::node_0_0_interleaved,
494 weighted_graph_description::node_0w_0_interleaved,
495 t.report("Set edge weight via zeroth partial weight"),
496 [](graph_t g) -> graph_t {
497 g.set_edge_weight(g.cbegin_edges(0), 1.0);
498 return g;
499 }
500 );
501
502 trg.join(
503 graph_description::node_0_0_interleaved,
504 weighted_graph_description::node_0_0w_interleaved,
505 t.report("Set edge weight via first partial weight"),
506 [](graph_t g) -> graph_t {
507 g.set_edge_weight(++g.cbegin_edges(0), 1.0);
508 return g;
509 }
510 );
511
512 trg.join(
513 graph_description::node_0_0_interleaved,
514 weighted_graph_description::node_0w_0_interleaved,
515 t.report("Set edge weight via second partial weight"),
516 [](graph_t g) -> graph_t {
517 g.set_edge_weight(g.cbegin_edges(0)+2, 1.0);
518 return g;
519 }
520 );
521
522 trg.join(
523 graph_description::node_0_0_interleaved,
524 weighted_graph_description::node_0_0w_interleaved,
525 t.report("Set edge weight via third partial weight"),
526 [](graph_t g) -> graph_t {
527 g.set_edge_weight(g.cbegin_edges(0)+3, 1.0);
528 return g;
529 }
530 );
531
532 trg.join(
533 graph_description::node_0_0_interleaved,
534 weighted_graph_description::node_0w_0_interleaved,
535 t.report("Muteate edge weight via zeroth partial weight"),
536 [](graph_t g) -> graph_t {
537 g.mutate_edge_weight(g.cbegin_edges(0), [](double& x) { x += 1.0; });
538 return g;
539 }
540 );
541
542 trg.join(
543 graph_description::node_0_0_interleaved,
544 weighted_graph_description::node_0_0w_interleaved,
545 t.report("Mutate edge weight via first partial weight"),
546 [](graph_t g) -> graph_t {
547 g.mutate_edge_weight(++g.cbegin_edges(0), [](double& x) { x += 1.0; });
548 return g;
549 }
550 );
551
552 trg.join(
553 graph_description::node_0_0_interleaved,
554 weighted_graph_description::node_0w_0_interleaved,
555 t.report("Mutate edge weight via second partial weight"),
556 [](graph_t g) -> graph_t {
557 g.mutate_edge_weight(g.cbegin_edges(0) + 2, [](double& x) { x += 1.0; });
558 return g;
559 }
560 );
561
562 trg.join(
563 graph_description::node_0_0_interleaved,
564 weighted_graph_description::node_0_0w_interleaved,
565 t.report("Mutate edge weight via third partial weight"),
566 [](graph_t g) -> graph_t {
567 g.mutate_edge_weight(g.cbegin_edges(0) + 3, [](double& x) { x += 1.0; });
568 return g;
569 }
570 );
571
572 // end 'graph_description::node_0_0_interleaved'
573
574 // begin 'graph_description::node_1_node_0'
575
576 trg.join(
577 graph_description::node_1_node_0,
578 weighted_graph_description::node_1w_1_node_0_0w,
579 t.report("Inserted braided join"),
580 [](graph_t g) -> graph_t {
581 g.insert_join(g.cbegin_edges(0), g.cbegin_edges(1)+1, 1.0);
582 return g;
583 }
584 );
585
586 trg.join(
587 graph_description::node_1_node_0,
588 weighted_graph_description::node_1_1w_node_0w_0,
589 t.report("Inserted braided join"),
590 [](graph_t g) -> graph_t {
591 g.insert_join(g.cbegin_edges(0) + 1, g.cbegin_edges(1), 1.0);
592 return g;
593 }
594 );
595
596 // end 'graph_description::node_1_node_0'
597
598 // begin 'graph_description::node_1_1_node_0_0'
599
600 trg.join(
601 graph_description::node_1_1_node_0_0,
602 weighted_graph_description::node_1_1w_node_0_0w,
603 t.report("Set edge weight via node 0, first partial edge"),
604 [](graph_t g) -> graph_t {
605 g.set_edge_weight(++g.cbegin_edges(0), 1.0);
606 return g;
607 }
608 );
609
610 trg.join(
611 graph_description::node_1_1_node_0_0,
612 weighted_graph_description::node_1_1w_node_0_0w,
613 t.report("Set edge weight via node 1, first partial edge"),
614 [](graph_t g) -> graph_t {
615 g.set_edge_weight(++g.cbegin_edges(1), 1.0);
616 return g;
617 }
618 );
619
620 trg.join(
621 graph_description::node_1_1_node_0_0,
622 weighted_graph_description::node_1_1w_node_0_0w,
623 t.report("Mutate edge weight via node 0, first partial edge"),
624 [](graph_t g) -> graph_t {
625 g.mutate_edge_weight(++g.cbegin_edges(0), [](double& x) { x += 1.0; });
626 return g;
627 }
628 );
629
630 trg.join(
631 graph_description::node_1_1_node_0_0,
632 weighted_graph_description::node_1_1w_node_0_0w,
633 t.report("Mutate edge weight via node 1, first partial edge"),
634 [](graph_t g) -> graph_t {
635 g.mutate_edge_weight(++g.cbegin_edges(1), [](double& x) { x += 1.0; });
636 return g;
637 }
638 );
639
640 // end 'graph_description::node_1_1_node_0_0'
641
642 // begin 'graph_description::node_1pos1_1pos0_node_0pos1_0pos0'
643
644 trg.join(
645 graph_description::node_1pos1_1pos0_node_0pos1_0pos0,
646 weighted_graph_description::node_1w_1_node_0_0w,
647 t.report("Set edge weight via node 0, zeroth partial edge"),
648 [](graph_t g) -> graph_t {
649 g.set_edge_weight(g.cbegin_edges(0), 1.0);
650 return g;
651 }
652 );
653
654 trg.join(
655 graph_description::node_1pos1_1pos0_node_0pos1_0pos0,
656 weighted_graph_description::node_1_1w_node_0w_0,
657 t.report("Set edge weight via node 0, first partial edge"),
658 [](graph_t g) -> graph_t {
659 g.set_edge_weight(g.cbegin_edges(0) + 1, 1.0);
660 return g;
661 }
662 );
663
664 trg.join(
665 graph_description::node_1pos1_1pos0_node_0pos1_0pos0,
666 weighted_graph_description::node_1_1w_node_0w_0,
667 t.report("Set edge weight via node 1, zeroth partial edge"),
668 [](graph_t g) -> graph_t {
669 g.set_edge_weight(g.cbegin_edges(1), 1.0);
670 return g;
671 }
672 );
673
674 trg.join(
675 graph_description::node_1pos1_1pos0_node_0pos1_0pos0,
676 weighted_graph_description::node_1w_1_node_0_0w,
677 t.report("Set edge weight via node 1, first partial edge"),
678 [](graph_t g) -> graph_t {
679 g.set_edge_weight(g.cbegin_edges(1) + 1, 1.0);
680 return g;
681 }
682 );
683
684 trg.join(
685 graph_description::node_1pos1_1pos0_node_0pos1_0pos0,
686 weighted_graph_description::node_1w_1_node_0_0w,
687 t.report("Mutate edge weight via node 0, zeroth partial edge"),
688 [](graph_t g) -> graph_t {
689 g.mutate_edge_weight(g.cbegin_edges(0), [](double& x) { x += 1.0; });
690 return g;
691 }
692 );
693
694 trg.join(
695 graph_description::node_1pos1_1pos0_node_0pos1_0pos0,
696 weighted_graph_description::node_1_1w_node_0w_0,
697 t.report("Mutate edge weight via node 0, first partial edge"),
698 [](graph_t g) -> graph_t {
699 g.mutate_edge_weight(g.cbegin_edges(0) + 1, [](double& x) { x += 1.0; });
700 return g;
701 }
702 );
703
704 trg.join(
705 graph_description::node_1pos1_1pos0_node_0pos1_0pos0,
706 weighted_graph_description::node_1_1w_node_0w_0,
707 t.report("Mutate edge weight via node 1, zeroth partial edge"),
708 [](graph_t g) -> graph_t {
709 g.mutate_edge_weight(g.cbegin_edges(1), [](double& x) { x += 1.0; });
710 return g;
711 }
712 );
713
714 trg.join(
715 graph_description::node_1pos1_1pos0_node_0pos1_0pos0,
716 weighted_graph_description::node_1w_1_node_0_0w,
717 t.report("Mutate edge weight via node 1, first partial edge"),
718 [](graph_t g) -> graph_t {
719 g.mutate_edge_weight(g.cbegin_edges(1) + 1, [](double& x) { x += 1.0; });
720 return g;
721 }
722 );
723
724 // end 'graph_description::node_1pos1_1pos0_node_0pos1_0pos0'
725
726 //======================================= joins from new nodes =======================================//
727
728 // begin 'weighted_graph_description::node_0w'
729
730 trg.join(
731 weighted_graph_description::node_0w,
732 weighted_graph_description::node_0_0w_interleaved,
733 t.report("Insert join {0,0}"),
734 [](graph_t g) -> graph_t {
735 g.insert_join(g.cbegin_edges(0), 2, 0.0);
736 return g;
737 }
738 );
739
740 trg.join(
741 weighted_graph_description::node_0w,
742 weighted_graph_description::node_0w_0_interleaved,
743 t.report("Insert join {0,0}"),
744 [](graph_t g) -> graph_t {
745 g.insert_join(g.cbegin_edges(0)+1, 3, 0.0);
746 return g;
747 }
748 );
749
750 // end 'weighted_graph_description::node_0w'
751
752 // begin 'weighted_graph_description::node_0_0w'
753
754 trg.join(
755 weighted_graph_description::node_0_0w,
756 weighted_graph_description::node_0w,
757 t.report("Remove zeroth partial edge"),
758 [](graph_t g) -> graph_t {
759 g.erase_edge(g.cbegin_edges(0));
760 return g;
761 }
762 );
763
764 trg.join(
765 weighted_graph_description::node_0_0w,
766 weighted_graph_description::node_0w,
767 t.report("Remove first partial edge"),
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_0_0w,
776 graph_description::node_0,
777 t.report("Remove second partial edge"),
778 [](graph_t g) -> graph_t {
779 g.erase_edge(g.cbegin_edges(0)+2);
780 return g;
781 }
782 );
783
784 trg.join(
785 weighted_graph_description::node_0_0w,
786 graph_description::node_0,
787 t.report("Remove third partial edge"),
788 [](graph_t g) -> graph_t {
789 g.erase_edge(g.cbegin_edges(0)+3);
790 return g;
791 }
792 );
793
794 // end 'weighted_graph_description::node_0_0w'
795
796 // begin 'graph_description::node_0w_0_interleaved'
797
798 trg.join(
799 weighted_graph_description::node_0w_0_interleaved,
800 graph_description::node_0_0_interleaved,
801 t.report("Set edge weight via zeroth partial weight"),
802 [](graph_t g) -> graph_t {
803 g.set_edge_weight(g.cbegin_edges(0), 0.0);
804 return g;
805 }
806 );
807
808 trg.join(
809 weighted_graph_description::node_0w_0_interleaved,
810 weighted_graph_description::node_0w_0w_interleaved,
811 t.report("Set edge weight via first partial weight"),
812 [](graph_t g) -> graph_t {
813 g.set_edge_weight(++g.cbegin_edges(0), 1.0);
814 return g;
815 }
816 );
817
818 trg.join(
819 weighted_graph_description::node_0w_0_interleaved,
820 graph_description::node_0_0_interleaved,
821 t.report("Set edge weight via second partial weight"),
822 [](graph_t g) -> graph_t {
823 g.set_edge_weight(g.cbegin_edges(0) + 2, 0.0);
824 return g;
825 }
826 );
827
828 trg.join(
829 weighted_graph_description::node_0w_0_interleaved,
830 weighted_graph_description::node_0w_0w_interleaved,
831 t.report("Set edge weight via third partial weight"),
832 [](graph_t g) -> graph_t {
833 g.set_edge_weight(g.cbegin_edges(0) + 3, 1.0);
834 return g;
835 }
836 );
837
838 trg.join(
839 weighted_graph_description::node_0w_0_interleaved,
840 graph_description::node_0_0_interleaved,
841 t.report("Muteate edge weight via zeroth partial weight"),
842 [](graph_t g) -> graph_t {
843 g.mutate_edge_weight(g.cbegin_edges(0), [](double& x) { x -= 1.0; });
844 return g;
845 }
846 );
847
848 trg.join(
849 weighted_graph_description::node_0w_0_interleaved,
850 weighted_graph_description::node_0w_0w_interleaved,
851 t.report("Mutate edge weight via first partial weight"),
852 [](graph_t g) -> graph_t {
853 g.mutate_edge_weight(++g.cbegin_edges(0), [](double& x) { x += 1.0; });
854 return g;
855 }
856 );
857
858 trg.join(
859 weighted_graph_description::node_0w_0_interleaved,
860 graph_description::node_0_0_interleaved,
861 t.report("Mutate edge weight via second partial weight"),
862 [](graph_t g) -> graph_t {
863 g.mutate_edge_weight(g.cbegin_edges(0) + 2, [](double& x) { x -= 1.0; });
864 return g;
865 }
866 );
867
868 trg.join(
869 weighted_graph_description::node_0w_0_interleaved,
870 weighted_graph_description::node_0w_0w_interleaved,
871 t.report("Mutate edge weight via third partial weight"),
872 [](graph_t g) -> graph_t {
873 g.mutate_edge_weight(g.cbegin_edges(0) + 3, [](double& x) { x += 1.0; });
874 return g;
875 }
876 );
877
878 // end 'graph_description::node_0w_0_interleaved'
879
880 // begin 'weighted_graph_description::node_nodew'
881
882 trg.join(
883 weighted_graph_description::node_nodew,
884 weighted_graph_description::nodew_node,
885 t.report("Swap nodes"),
886 [](graph_t g) -> graph_t {
887 g.swap_nodes(0, 1);
888 return g;
889 }
890 );
891
892 // end 'weighted_graph_description::node_nodew'
893
894 // begin 'weighted_graph_description::nodew_node'
895
896 trg.join(
897 weighted_graph_description::nodew_node,
898 weighted_graph_description::node_nodew,
899 t.report("Swap nodes"),
900 [](graph_t g) -> graph_t {
901 g.swap_nodes(1, 0);
902 return g;
903 }
904 );
905
906 // end 'weighted_graph_description::nodew_node'
907
908 // begin 'weighted_graph_description::node_1_nodew_0'
909
910 trg.join(
911 weighted_graph_description::node_1_nodew_0,
912 weighted_graph_description::nodew_1_node_0,
913 t.report("Swap nodes"),
914 [](graph_t g) -> graph_t {
915 g.swap_nodes(0, 1);
916 return g;
917 }
918 );
919
920 // end 'weighted_graph_description::node_1_nodew_0'
921
922 // begin 'weighted_graph_description::nodew_node_0'
923
924 trg.join(
925 weighted_graph_description::nodew_1_node_0,
926 weighted_graph_description::node_1_nodew_0,
927 t.report("Swap nodes"),
928 [](graph_t g) -> graph_t {
929 g.swap_nodes(1, 0);
930 return g;
931 }
932 );
933
934 // end 'weighted_graph_description::nodew_node_0'
935
936 // begin 'weighted_graph_description::node_1_1w_node_0_0w'
937
938 trg.join(
939 weighted_graph_description::node_1_1w_node_0_0w,
940 weighted_graph_description::node_1w_1w_node_0w_0w,
941 t.report("Set edge weight {0, 1}"),
942 [](graph_t g) -> graph_t {
943 g.set_edge_weight(g.cbegin_edges(0), 1.0);
944 return g;
945 }
946 );
947
948 trg.join(
949 weighted_graph_description::node_1_1w_node_0_0w,
950 weighted_graph_description::node_1w_1w_node_0w_0w,
951 t.report("Set edge weight {1, 0}"),
952 [](graph_t g) -> graph_t {
953 g.set_edge_weight(g.cbegin_edges(1), 1.0);
954 return g;
955 }
956 );
957
958 // end 'weighted_graph_description::node_1_1w_node_0_0w'
959
960 // begin 'weighted_graph_description::node_1w_1w_node_0w_0w'
961
962 trg.join(
963 weighted_graph_description::node_1w_1w_node_0w_0w,
964 weighted_graph_description::node_1_1w_node_0_0w,
965 t.report("Set edge weight {0, 1}"),
966 [](graph_t g) -> graph_t {
967 g.set_edge_weight(g.cbegin_edges(0), 0.0);
968 return g;
969 }
970 );
971
972 trg.join(
973 weighted_graph_description::node_1w_1w_node_0w_0w,
974 weighted_graph_description::node_1_1w_node_0_0w,
975 t.report("Set edge weight {1, 0}"),
976 [](graph_t g) -> graph_t {
977 g.set_edge_weight(g.cbegin_edges(1), 0.0);
978 return g;
979 }
980 );
981
982 trg.join(
983 weighted_graph_description::node_1w_1w_node_0w_0w,
984 weighted_graph_description::node_1_1w_node_0_0w,
985 t.report("Mutate edge weight {0, 1}"),
986 [](graph_t g) -> graph_t {
987 g.mutate_edge_weight(g.cbegin_edges(0), [](double& x){ x -= 1.0; });
988 return g;
989 }
990 );
991
992 trg.join(
993 weighted_graph_description::node_1w_1w_node_0w_0w,
994 weighted_graph_description::node_1_1w_node_0_0w,
995 t.report("Mutate edge weight {1, 0}"),
996 [](graph_t g) -> graph_t {
997 g.mutate_edge_weight(g.cbegin_edges(1), [](double& x){ x -= 1.0; });
998 return g;
999 }
1000 );
1001
1002 // end 'weighted_graph_description::node_1w_1w_node_0w_0w'
1003
1004 // begin 'weighted_graph_description::node_1_1w_1x_node_0_0w_0x'
1005
1006 trg.join(
1007 weighted_graph_description::node_1_1w_1x_node_0_0w_0x,
1008 weighted_graph_description::node_0y_1_1w_1x_node_0_0w_0x,
1009 t.report("Join {0,0} and sort"),
1010 [](graph_t g) -> graph_t {
1011 g.insert_join(g.cbegin_edges(0), 1, 3.0);
1012 return g;
1013 }
1014 );
1015
1016 // end 'weighted_graph_description::node_1_1w_1x_node_0_0w_0x'
1017
1018 // begin 'weighted_graph_description::node_0y_1_1w_1x_node_0_0w_0x'
1019
1020 trg.join(
1021 weighted_graph_description::node_0y_1_1w_1x_node_0_0w_0x,
1022 weighted_graph_description::node_1_1w_1x_node_0_0w_0x,
1023 t.report("Remove zeroth partial edge"),
1024 [](graph_t g) -> graph_t {
1025 g.erase_edge(g.cbegin_edges(0));
1026 return g;
1027 }
1028 );
1029
1030 trg.join(
1031 weighted_graph_description::node_0y_1_1w_1x_node_0_0w_0x,
1032 weighted_graph_description::node_1_1w_1x_node_0_0w_0x,
1033 t.report("Remove first partial edge"),
1034 [](graph_t g) -> graph_t {
1035 g.erase_edge(++g.cbegin_edges(0));
1036 return g;
1037 }
1038 );
1039
1040 // end'weighted_graph_description::node_0y_1_1w_1x_node_0_0w_0x'
1041
1042 return trg;
1043 }
1044 };
1045
1046
1047}
weighted_graph_description
Convention: the indices following 'node' - separated by underscores - give the target node of the ass...
Definition: DynamicUndirectedEmbeddedGraphWeightedTestingUtilities.hpp:18
Definition: DynamicGraph.hpp:303
Definition: DynamicGraph.hpp:473
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: DynamicUndirectedEmbeddedGraphTestingUtilities.hpp:215
Definition: DynamicUndirectedEmbeddedGraphWeightedTestingUtilities.hpp:111
Definition: DynamicGraphTestingUtilities.hpp:173
Definition: StateTransitionUtilities.hpp:77