15namespace sequoia::testing
17 using bfs_type = maths::breadth_first_search_type;
18 using dfs_type = maths::depth_first_search_type;
19 using pdfs_type = maths::pseudo_depth_first_search_type;
20 using prs_type = maths::priority_first_search_type;
23 std::string to_string(maths::traversal_flavour f);
26 template<maths::traversal_flavour F>
29 template<>
struct Traverser<maths::traversal_flavour::breadth_first>
31 constexpr static auto flavour{maths::traversal_flavour::breadth_first};
33 template<
class G, maths::disconnected_discovery_mode Mode,
class... Fn>
36 maths::traverse(maths::breadth_first, g, conditions, std::forward<Fn>(fn)...);
39 constexpr static bool uses_forward_iterator()
noexcept {
return true; }
41 static std::string iterator_description()
noexcept {
return "forward"; }
44 template<>
struct Traverser<maths::traversal_flavour::depth_first>
46 constexpr static auto flavour{maths::traversal_flavour::depth_first};
48 template<
class G, maths::disconnected_discovery_mode Mode,
class... Fn>
51 maths::traverse(maths::depth_first, g, conditions, std::forward<Fn>(fn)...);
54 constexpr static bool uses_forward_iterator()
noexcept {
return true; }
56 static std::string iterator_description()
noexcept {
return "forward"; }
59 template<>
struct Traverser<maths::traversal_flavour::pseudo_depth_first>
61 constexpr static auto flavour{maths::traversal_flavour::pseudo_depth_first};
63 template<
class G, maths::disconnected_discovery_mode Mode,
class... Fn>
66 maths::traverse(maths::pseudo_depth_first, g, conditions, std::forward<Fn>(fn)...);
69 constexpr static bool uses_forward_iterator()
noexcept {
return false; }
71 static std::string iterator_description()
noexcept {
return "reverse"; }
74 template<>
struct Traverser<maths::traversal_flavour::priority>
76 constexpr static auto flavour{maths::traversal_flavour::priority};
78 template<
class G, maths::disconnected_discovery_mode Mode,
class... Fn>
81 maths::traverse(maths::priority_first, g, conditions, std::forward<Fn>(fn)...);
84 constexpr static bool uses_forward_iterator()
noexcept {
return true; }
86 static std::string iterator_description()
noexcept {
return "forward"; }
92 void clear()
noexcept { m_Order.clear(); }
94 void operator()(
const std::size_t index) { m_Order.push_back(index); }
97 auto begin()
const noexcept
99 return m_Order.begin();
103 auto end()
const noexcept
105 return m_Order.end();
108 std::vector<std::size_t> m_Order;
111 template<maths::network G, maths::traversal_flavour Flavour>
115 using result_type = std::vector<std::pair<std::size_t, std::size_t>>;
119 void clear()
noexcept { m_Order.clear(); }
121 template<std::input_or_output_iterator I>
void operator()(I iter)
124 m_Order.emplace_back(iter.partition_index(),
static_cast<std::size_t
>(pos));
128 auto begin()
const noexcept
130 return m_Order.begin();
134 auto end()
const noexcept
136 return m_Order.end();
142 template<std::input_or_output_iterator I> [[nodiscard]]
auto dist(
pdfs_type, I iter)
144 return distance(m_Graph.crbegin_edges(iter.partition_index()), iter);
147 template<std::input_or_output_iterator I> [[nodiscard]]
auto dist(
bfs_type, I iter)
149 return distance(m_Graph.cbegin_edges(iter.partition_index()), iter);
152 template<std::input_or_output_iterator I> [[nodiscard]]
auto dist(
dfs_type, I iter)
154 return distance(m_Graph.cbegin_edges(iter.partition_index()), iter);
161 template<test_mode Mode>
164 check(equality,
"Visitation Order", logger, tracker.begin(), tracker.end(), prediction.begin(), prediction.end());
168 template<maths::network G, maths::traversal_flavour Flavour>
172 using prediction_type =
typename type::result_type;
174 template<test_mode Mode>
177 check(equality,
"Visitation Order", logger, tracker.begin(), tracker.end(), prediction.begin(), prediction.end());
Headers for traversals of dynamic graphs.
bool check(CheckType flavour, std::string description, test_logger< Mode > &logger, Iter first, Sentinel last, PredictionIter predictionFirst, PredictionSentinel predictionLast, tutor< Advisor > advisor={})
The workhorse for comparing the contents of ranges.
Definition: FreeCheckers.hpp:377
Definition: GraphTraversalDetails.hpp:72
Definition: GraphTraversalTestingUtilities.hpp:113
Definition: GraphTraversalTestingUtilities.hpp:90
Definition: TestLogger.hpp:183
Definition: GraphTraversalDetails.hpp:34
Definition: GraphTraversalTestingUtilities.hpp:27
Definition: FreeCheckers.hpp:87
class template, specializations of which implement various comparisons for the specified type.
Definition: FreeCheckers.hpp:78