Sequoia
Loading...
Searching...
No Matches
GraphTraversalFunctions.hpp
Go to the documentation of this file.
1
2// Copyright Oliver J. Rosten 2018. //
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
19
20namespace sequoia::maths
21{
22 template
23 <
24 class TaskProcessingModel = concurrency::serial<void>,
25 traversal_flavour F,
26 network G,
27 disconnected_discovery_mode Mode,
28 class NBEF = null_func_obj,
29 class NAEF = null_func_obj,
30 class EFTF = null_func_obj,
31 class ESTF = null_func_obj
32 >
33 requires (!is_directed(G::flavour))
34 && (std::invocable<NBEF, typename G::edge_index_type>)
35 && (std::invocable<NAEF, typename G::edge_index_type>)
36 && (std::invocable<EFTF, typename G::const_edge_iterator>)
37 && (std::invocable<ESTF, typename G::const_edge_iterator>)
38 constexpr auto traverse(traversal_constant<F> tc,
39 const G& graph,
40 const traversal_conditions<Mode> conditions,
41 NBEF&& nodeBeforeEdgesFn = {},
42 NAEF&& nodeAfterEdgesFn = {},
43 EFTF&& edgeFirstTraversalFn = {},
44 ESTF&& edgeSecondTraversalFn = {},
45 TaskProcessingModel&& taskProcessingModel = {})
46 {
47 return graph_impl::traversal_helper<G>{}.traverse(
48 tc,
49 graph,
50 conditions,
51 std::forward<NBEF>(nodeBeforeEdgesFn),
52 std::forward<NAEF>(nodeAfterEdgesFn),
53 std::forward<EFTF>(edgeFirstTraversalFn),
54 std::forward<ESTF>(edgeSecondTraversalFn),
55 std::forward<TaskProcessingModel>(taskProcessingModel)
56 );
57 }
58
59 template
60 <
61 class TaskProcessingModel = concurrency::serial<void>,
62 traversal_flavour F,
63 network G,
64 disconnected_discovery_mode Mode,
65 class NBEF = null_func_obj,
66 class NAEF = null_func_obj,
67 class EFTF = null_func_obj
68 >
69 requires (is_directed(G::flavour))
70 && (std::invocable<NBEF, typename G::edge_index_type>)
71 && (std::invocable<NAEF, typename G::edge_index_type>)
72 && (std::invocable<EFTF, typename G::const_edge_iterator>)
73 constexpr auto traverse(traversal_constant<F> tc,
74 const G& graph,
75 const traversal_conditions<Mode> conditions,
76 NBEF&& nodeBeforeEdgesFn = {},
77 NAEF&& nodeAfterEdgesFn = {},
78 EFTF&& edgeFirstTraversalFn = {},
79 TaskProcessingModel&& taskProcessingModel = {})
80 {
81 return graph_impl::traversal_helper<G>{}.traverse(
82 tc,
83 graph,
84 conditions,
85 std::forward<NBEF>(nodeBeforeEdgesFn),
86 std::forward<NAEF>(nodeAfterEdgesFn),
87 std::forward<EFTF>(edgeFirstTraversalFn),
88 null_func_obj{},
89 std::forward<TaskProcessingModel>(taskProcessingModel)
90 );
91 }
92
93 template
94 <
95 class TaskProcessingModel = concurrency::serial<void>,
96 network G,
97 disconnected_discovery_mode Mode,
98 class NBEF = null_func_obj,
99 class NAEF = null_func_obj,
100 class ETUN = null_func_obj
101 >
102 requires (std::invocable<NBEF, typename G::edge_index_type>)
103 && (std::invocable<NAEF, typename G::edge_index_type>)
104 && (std::invocable<ETUN, typename G::const_edge_iterator>)
105 constexpr auto traverse(depth_first_search_type,
106 const G& graph,
107 const traversal_conditions<Mode> conditions,
108 NBEF&& nodeBeforeEdgesFn = {},
109 NAEF&& nodeAfterEdgesFn = {},
110 ETUN&& edgeToUndiscoveredNodeFn = {},
111 TaskProcessingModel&& taskProcessingModel = {})
112 {
113 return graph_impl::traversal_helper<G>{}.traverse(
114 depth_first,
115 graph,
116 conditions,
117 std::forward<NBEF>(nodeBeforeEdgesFn),
118 std::forward<NAEF>(nodeAfterEdgesFn),
119 std::forward<ETUN>(edgeToUndiscoveredNodeFn),
120 std::forward<TaskProcessingModel>(taskProcessingModel)
121 );
122 }
123
124 template
125 <
126 class TaskProcessingModel = concurrency::serial<void>,
127 network G,
128 disconnected_discovery_mode Mode,
129 class NBEF = null_func_obj,
130 class NAEF = null_func_obj,
131 class EFTF = null_func_obj,
132 class ESTF = null_func_obj,
133 class QCompare = graph_impl::node_comparer<G, std::ranges::less>
134 >
135 requires (!is_directed(G::flavour))
136 && (std::invocable<NBEF, typename G::edge_index_type>)
137 && (std::invocable<NAEF, typename G::edge_index_type>)
138 && (std::invocable<EFTF, typename G::const_edge_iterator>)
139 && (std::invocable<ESTF, typename G::const_edge_iterator>)
140 constexpr auto traverse(priority_first_search_type,
141 const G& graph,
142 const traversal_conditions<Mode> conditions,
143 NBEF&& nodeBeforeEdgesFn = {},
144 NAEF&& nodeAfterEdgesFn = {},
145 EFTF&& edgeFirstTraversalFn = {},
146 ESTF&& edgeSecondTraversalFn = {},
147 TaskProcessingModel&& taskProcessingModel = {})
148 {
149 return graph_impl::traversal_helper<G>{}.traverse(
150 priority_first,
151 graph,
152 conditions,
153 std::forward<NBEF>(nodeBeforeEdgesFn),
154 std::forward<NAEF>(nodeAfterEdgesFn),
155 std::forward<EFTF>(edgeFirstTraversalFn),
156 std::forward<ESTF>(edgeSecondTraversalFn),
157 std::forward<TaskProcessingModel>(taskProcessingModel),
158 QCompare{graph}
159 );
160 }
161
162 template
163 <
164 class TaskProcessingModel = concurrency::serial<void>,
165 network G,
166 disconnected_discovery_mode Mode,
167 class NBEF = null_func_obj,
168 class NAEF = null_func_obj,
169 class EFTF = null_func_obj,
170 class QCompare = graph_impl::node_comparer<G, std::ranges::less>
171 >
172 requires (is_directed(G::flavour))
173 && (std::invocable<NBEF, typename G::edge_index_type>)
174 && (std::invocable<NAEF, typename G::edge_index_type>)
175 && (std::invocable<EFTF, typename G::const_edge_iterator>)
176 constexpr auto traverse(priority_first_search_type,
177 const G& graph,
178 const traversal_conditions<Mode> conditions,
179 NBEF&& nodeBeforeEdgesFn = {},
180 NAEF&& nodeAfterEdgesFn = {},
181 EFTF&& edgeFirstTraversalFn = {},
182 TaskProcessingModel&& taskProcessingModel = {})
183 {
184 return graph_impl::traversal_helper<G>{}.traverse(
185 priority_first,
186 graph,
187 conditions,
188 std::forward<NBEF>(nodeBeforeEdgesFn),
189 std::forward<NAEF>(nodeAfterEdgesFn),
190 std::forward<EFTF>(edgeFirstTraversalFn),
191 null_func_obj{},
192 std::forward<TaskProcessingModel>(taskProcessingModel),
193 QCompare{graph}
194 );
195 }
196}
Classes with a queue-like behaviour to which tasks can be pushed and results recovered,...
Meta-prorgamming utilities for traversals of dynamic graphs.
Meta-programming urilities and underlying function for graph traversals.
Meta-programming utilities for traversals of static graphs.