Sequoia
Loading...
Searching...
No Matches
DynamicGraphTestingUtilities.hpp
Go to the documentation of this file.
1
2// Copyright Oliver J. Rosten 2019. //
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
15
18
19#include <variant>
20
21namespace sequoia::testing
22{
23 // Edge Storage Container
24
26 {
28
29 constexpr static maths::edge_sharing_preference edge_sharing{maths::edge_sharing_preference::independent};
30 };
31
33 {
34 template <class T> using storage_type = data_structures::bucketed_sequence<T>;
35
36 constexpr static maths::edge_sharing_preference edge_sharing{maths::edge_sharing_preference::independent};
37 };
38
40 {
42
43 constexpr static maths::edge_sharing_preference edge_sharing{maths::edge_sharing_preference::shared_weight};
44 };
45
47 {
48 template <class T> using storage_type = data_structures::bucketed_sequence<T>;
49
50 constexpr static maths::edge_sharing_preference edge_sharing{maths::edge_sharing_preference::shared_weight};
51 };
52
53 // Meta
54
55 [[nodiscard]]
56 constexpr bool embedded(const maths::graph_flavour graphFlavour) noexcept
57 {
58 using gf = maths::graph_flavour;
59 return graphFlavour == gf::undirected_embedded;
60 }
61
62 template
63 <
64 maths::graph_flavour GraphFlavour,
65 class EdgeWeight,
66 class NodeWeight,
67 class EdgeStorageConfig,
68 class NodeWeightStorage
69 >
71 {
73 };
74
75 template
76 <
77 maths::graph_flavour GraphFlavour,
78 class EdgeWeight,
79 class NodeWeight,
80 class EdgeStorageConfig,
81 class NodeWeightStorage
82 >
83 requires (GraphFlavour == maths::graph_flavour::undirected)
85 {
87 };
88
89 template
90 <
91 maths::graph_flavour GraphFlavour,
92 class EdgeWeight,
93 class NodeWeight,
94 class EdgeStorageConfig,
95 class NodeWeightStorage
96 >
97 requires (GraphFlavour == maths::graph_flavour::undirected_embedded)
99 {
101 };
102
103 template
104 <
105 maths::graph_flavour GraphFlavour,
106 class EdgeWeight,
107 class NodeWeight,
108 class EdgeStorageConfig,
109 class NodeWeightStorage
110 >
111 using graph_type_generator_t = typename graph_type_generator<GraphFlavour, EdgeWeight, NodeWeight, EdgeStorageConfig, NodeWeightStorage>::graph_type;
112
113 template <class EdgeWeight, class NodeWeight, concrete_test Test>
115 {
116 public:
117 explicit graph_test_helper(Test& t) : m_Test{t}
118 {}
119
120 void run_tests()
121 {
122 using flavour = maths::graph_flavour;
123
124 run_tests<flavour::undirected>();
125 if constexpr(!minimal_graph_tests())
126 {
127 run_tests<flavour::undirected_embedded>();
128 run_tests<flavour::directed>();
129 }
130 }
131
132 template<class EdgeStorageConfig, class NodeWeightStorage>
133 void run_tests()
134 {
135 using flavour = maths::graph_flavour;
136 creation_permutations<flavour::undirected, EdgeStorageConfig, NodeWeightStorage>();
137 if constexpr (!minimal_graph_tests())
138 {
139 creation_permutations<flavour::undirected_embedded, EdgeStorageConfig, NodeWeightStorage>();
140 creation_permutations<flavour::directed, EdgeStorageConfig, NodeWeightStorage>();
141 }
142 }
143
144 template<maths::graph_flavour GraphFlavour>
145 void run_tests()
146 {
147 creation_permutations<GraphFlavour, maths::contiguous_edge_storage_config, maths::node_storage<NodeWeight>>();
148 creation_permutations<GraphFlavour, maths::bucketed_edge_storage_config, maths::node_storage<NodeWeight>>();
149 }
150 private:
151 Test& m_Test;
152
153 template
154 <
155 maths::graph_flavour GraphFlavour,
156 class EdgeStorageConfig,
157 class NodeWeightStorage
158 >
159 void creation_permutations()
160 {
161 m_Test.template execute_operations<
162 GraphFlavour,
163 EdgeWeight,
164 NodeWeight,
165 EdgeStorageConfig,
166 NodeWeightStorage
167 >();
168 }
169 };
170
171 template<maths::network G>
173 {
174 using edge_type = typename G::edge_init_type;
175 using node_weight_type = typename G::node_weight_type;
176
177 template<class Test>
178 [[nodiscard]]
179 static G make_and_check(Test& t, std::string_view description, std::initializer_list<std::initializer_list<edge_type>> init)
180 {
181 G g{init};
182 t.check(equivalence, description, g, init);
183 return g;
184 }
185
186 template<class Test>
187 [[nodiscard]]
188 static G make_and_check(Test& t, std::string_view description, std::initializer_list<std::initializer_list<edge_type>> edgeInit, std::initializer_list<node_weight_type> nodeInit)
189 {
190 G g{edgeInit, nodeInit};
191 t.check(equivalence, description, g, std::pair{edgeInit, nodeInit});
192 return g;
193 }
194 };
195}
Edge & Node storage traits, base class and final classes for dynamic graphs.
Central location for pre-processor options.
Storage for partitioned data such that data within each partition is contiguous.
Definition: PartitionedData.hpp:63
Definition: PartitionedData.hpp:991
Definition: DynamicGraph.hpp:303
Definition: DynamicGraph.hpp:473
Definition: DynamicGraph.hpp:360
Definition: DynamicGraphTestingUtilities.hpp:115
Definition: DynamicGraphTestingUtilities.hpp:173
Definition: DynamicGraphTestingUtilities.hpp:71
Definition: DynamicGraphTestingUtilities.hpp:33
Definition: DynamicGraphTestingUtilities.hpp:26
Definition: DynamicGraphTestingUtilities.hpp:47
Definition: DynamicGraphTestingUtilities.hpp:40