Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
Data Structures | Static Public Member Functions
graph::traverse::DFS Class Reference

#include <DFS.hpp>

Static Public Member Functions

template<typename TGraph , typename TNode , typename F = std::function<bool(const TNode &, const size_t &)>>
static void run (const TGraph &graph, const TNode &start, F f_user=[](const TNode &, const size_t &) -> bool { return false;})
 
template<typename TGraph , typename TNode , typename F = std::function<void(const TNode &, const size_t &)>>
static ext::vector< TNode > findPath (const TGraph &graph, const TNode &start, const TNode &goal, F f_user=[](const TNode &, const size_t &) {})
 
template<typename TGraph , typename TNode >
static ext::vector< TNode > findPathRegistration (const TGraph &graph, const TNode &start, const TNode &goal)
 

Member Function Documentation

◆ findPath()

template<typename TGraph , typename TNode , typename F >
ext::vector< TNode > graph::traverse::DFS::findPath ( const TGraph &  graph,
const TNode &  start,
const TNode &  goal,
f_user = [](const TNode &, const size_t &) {} 
)
static

Find path using DFS algorithm from the start node to the goal node in the graph. However, it is not quarantee that the return path gonna be the shortest one.

Whenever node is opened, f_user is called with two parameters (the opened node and distance to this node).

Parameters
graphto explore.
startinitial node.
goalfinal node.
f_userfunction which is called for every opened node with value of currently shortest path.
Returns
nodes in path, if there is no such path vector is empty.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ findPathRegistration()

template<typename TGraph , typename TNode >
static ext::vector< TNode > graph::traverse::DFS::findPathRegistration ( const TGraph &  graph,
const TNode &  start,
const TNode &  goal 
)
inlinestatic
Here is the call graph for this function:

◆ run()

template<typename TGraph , typename TNode , typename F >
void graph::traverse::DFS::run ( const TGraph &  graph,
const TNode &  start,
f_user = [](const TNode &, const size_t &) -> bool { return false; } 
)
static

Run DFS algorithm from the start node in the graph.

Whenever node is opened, f_user is called with two parameters (the opened node and distance to this node). If return of f_user is true, then the algorithm is stopped.

Parameters
graphto explore.
startinitial node.
f_userfunction which is called for every opened node with value of currently shortest path.
Here is the call graph for this function:

The documentation for this class was generated from the following file: