39 typename F = std::function<void(
const TNode &,
const size_t &)>>
44 F f_user = [](
const TNode &,
const size_t &) ->
bool {
return false; });
62 typename F = std::function<void(
const TNode &,
const size_t &)>>
68 F f_user = [](
const TNode &,
const size_t &) {});
70 template<
typename TGraph,
typename TNode>
97 typename F = std::function<void(
const TNode &,
const size_t &)>>
103 F f_user = [](
const TNode &,
const size_t &) {});
105 template<
typename TGraph,
typename TNode>
120 template<
typename TNode>
122 std::queue<TNode> queue;
130 template<
typename TGraph,
typename TNode,
typename F1,
typename F2>
133 implNormal(
const TGraph &
graph,
141 template<
typename FSucc,
typename TNode,
typename F1,
typename F2>
142 static bool expansion(FSucc successors,
149 template<
typename TGraph,
typename TNode,
typename F1>
152 implBidirectional(
const TGraph &
graph,
159 template<
typename TNode>
160 inline static void init(BFS::Data<TNode> &data,
const TNode &
start);
167template<
typename TGraph,
typename TNode,
typename F>
170 implNormal(
graph,
start,
start, f_user, [](
const TNode &) ->
bool {
return false; });
175template<
typename TGraph,
typename TNode,
typename F>
182 [&](
const TNode &n,
const size_t &d) ->
bool {
186 [&goal](
const TNode &n) ->
bool {
return goal == n; });
191template<
typename TGraph,
typename TNode,
typename F>
198 [&](
const TNode &n,
const size_t &d) ->
bool {
208template<
typename TGraph,
typename TNode,
typename F1,
typename F2>
210BFS::implNormal(
const TGraph &
graph,
220 while (!data.queue.empty()) {
221 bool stop = expansion([&](
const TNode &
node) {
return graph.successors(
node); }, data, f_user, f_stop);
234template<
typename FSucc,
typename TNode,
typename F1,
typename F2>
235bool BFS::expansion(FSucc successors,
239 TNode n = data.queue.front();
243 if (f_user(n, data.d[n])) {
252 for (
const auto &s : successors(n)) {
253 if (data.v.count(s) == 0) {
255 data.p.insert_or_assign(s, n);
265template<
typename TGraph,
typename TNode,
typename F1>
267BFS::implBidirectional(
const TGraph &
graph,
271 Data<TNode> forward_data;
272 Data<TNode> backward_data;
276 init(forward_data,
start);
279 init(backward_data, goal);
281 while (!forward_data.queue.empty() && !backward_data.queue.empty()) {
283 bool stop = expansion([&](
const TNode &
node) {
return graph.successors(
node); }, forward_data, f_user,
284 [&](
const TNode &n) {
285 if (backward_data.v.find(n) != backward_data.v.end()) {
286 intersection.push_back(n);
299 *intersection.
begin());
303 stop = expansion([&](
const TNode &
node) {
return graph.predecessors(
node); }, backward_data, f_user,
304 [&](
const TNode &n) {
305 if (forward_data.v.find(n) != forward_data.v.end()) {
306 intersection.push_back(n);
318 *intersection.
begin());
328template<
typename TNode>
329void BFS::init(BFS::Data<TNode> &data,
const TNode &
start) {
330 data.queue.push(
start);
331 data.v.insert(
start);
Class extending the map class from the standard library. Original reason is to allow printing of the ...
Definition: map.hpp:48
Class extending the vector class from the standard library. Original reason is to allow printing of t...
Definition: vector.hpp:45
auto begin() &
Inherited behavior of begin for non-const instance.
Definition: vector.hpp:125
static ext::vector< TNode > reconstructPath(const ext::map< TNode, TNode > &p, const TNode &start, const TNode &goal)
Definition: ReconstructPath.hpp:68
static ext::vector< TNode > findPath(const TGraph &graph, const TNode &start, const TNode &goal, F f_user=[](const TNode &, const size_t &) {})
Definition: BFS.hpp:177
static void run(const TGraph &graph, const TNode &start, F f_user=[](const TNode &, const size_t &) -> bool { return false;})
Definition: BFS.hpp:168
static ext::vector< TNode > findPathBidirectional(const TGraph &graph, const TNode &start, const TNode &goal, F f_user=[](const TNode &, const size_t &) {})
Definition: BFS.hpp:193
static ext::vector< TNode > findPathBidirectionalRegistration(const TGraph &graph, const TNode &start, const TNode &goal)
Definition: BFS.hpp:108
static ext::vector< TNode > findPathRegistration(const TGraph &graph, const TNode &start, const TNode &goal)
Definition: BFS.hpp:73
Definition: ReconstructPath.hpp:14
void start(measurements::stealth_string name, measurements::Type type)
Definition: measurements.cpp:14