Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Find_Path_Depth_First< GT, Itor, SA > Class Template Reference

Performs a depth-first search for a path between a pair of nodes. More...

#include <tpl_find_path.H>

Collaboration diagram for Aleph::Find_Path_Depth_First< GT, Itor, SA >:
[legend]

Classes

struct  Frame
 

Public Member Functions

 Find_Path_Depth_First (SA &&__sa=SA())
 
 Find_Path_Depth_First (SA &__sa)
 
bool operator() (const GT &g, typename GT::Node *start, typename GT::Node *end, Path< GT > &path)
 Invokes the depth-first path search.
 
Path< GT > operator() (const GT &g, typename GT::Node *start, typename GT::Node *end)
 Invokes the depth-first path search.
 
template<class Op >
Path< GT > operator() (const GT &g, typename GT::Node *start, Op &op)
 Invokes the depth-first path search.
 
template<class Op = Dft_Goal_Node<GT>>
Path< GT > operator() (const GT &g, typename GT::Node *start, Op &&op)
 

Private Member Functions

template<class Op >
GT::Node * next_target (Frame &f, Op &op, bool &found)
 
template<class Op >
bool find_path (Dfs_Stack< Frame > &frames, typename GT::Node *curr, typename GT::Arc *arc, Path< GT > &path, Op &op)
 
template<class Op >
bool find (const GT &g, typename GT::Node *start, Path< GT > &path, Op &op)
 
template<class Op >
bool find (const GT &g, typename GT::Node *start, Path< GT > &path, Op &&op)
 

Static Private Member Functions

static void remove_last_node (Path< GT > &path)
 

Private Attributes

Kept_Filter< SA > sa
 
GT * g_ptr = nullptr
 

Detailed Description

template<AlephGraph GT, template< class, class > class Itor = Node_Arc_Iterator, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
class Aleph::Find_Path_Depth_First< GT, Itor, SA >

Performs a depth-first search for a path between a pair of nodes.

Find_Path_Depth_First searches depth-first for a path between start_node and end_node, building a path equivalent to the depth of the search as it goes. If a path is found, the method returns true and the path parameter holds the path in question; otherwise, the function returns false and the path is empty.

The class takes two type parameters:

  1. GT: the graph type, which must be derived from List_Graph
  2. SA: class in charge of showing the arc. Internally, the function uses the filter iterator Node_Arc_Iterator (based on Filter_Iterator) to traverse the arcs of each node. SA is the class that determines whether or not the arc should be shown to the traversal
See also
find_path_breadth_first()
dijkstra_min_spanning_tree() dijkstra_min_path()
bellman_ford_min_spanning_tree() q_bellman_ford_min_spanning_tree()

Definition at line 97 of file tpl_find_path.H.

Constructor & Destructor Documentation

◆ Find_Path_Depth_First() [1/2]

template<AlephGraph GT, template< class, class > class Itor = Node_Arc_Iterator, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Aleph::Find_Path_Depth_First< GT, Itor, SA >::Find_Path_Depth_First ( SA &&  __sa = SA())
inline

Definition at line 259 of file tpl_find_path.H.

◆ Find_Path_Depth_First() [2/2]

template<AlephGraph GT, template< class, class > class Itor = Node_Arc_Iterator, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Aleph::Find_Path_Depth_First< GT, Itor, SA >::Find_Path_Depth_First ( SA &  __sa)
inline

Definition at line 264 of file tpl_find_path.H.

Member Function Documentation

◆ find() [1/2]

template<AlephGraph GT, template< class, class > class Itor = Node_Arc_Iterator, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
template<class Op >
bool Aleph::Find_Path_Depth_First< GT, Itor, SA >::find ( const GT &  g,
typename GT::Node *  start,
Path< GT > &  path,
Op &&  op 
)
inlineprivate

◆ find() [2/2]

◆ find_path()

◆ next_target()

◆ operator()() [1/4]

template<AlephGraph GT, template< class, class > class Itor = Node_Arc_Iterator, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
template<class Op = Dft_Goal_Node<GT>>
Path< GT > Aleph::Find_Path_Depth_First< GT, Itor, SA >::operator() ( const GT &  g,
typename GT::Node *  start,
Op &&  op 
)
inline

Definition at line 326 of file tpl_find_path.H.

◆ operator()() [2/4]

template<AlephGraph GT, template< class, class > class Itor = Node_Arc_Iterator, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
template<class Op >
Path< GT > Aleph::Find_Path_Depth_First< GT, Itor, SA >::operator() ( const GT &  g,
typename GT::Node *  start,
Op &  op 
)
inline

Invokes the depth-first path search.

Parameters
[in]gthe graph on which the path is to be searched.
[in]startpointer to the path's starting node.
[in]opfunctor that implements the search criterion. The functor receives the node as a parameter and must return true if the node satisfies the criterion, false otherwise.
Returns
path the path seen during the depth-first search; if no such path exists then the path is empty
Exceptions
bad_allocif there is not enough memory to keep building the path

Definition at line 318 of file tpl_find_path.H.

◆ operator()() [3/4]

template<AlephGraph GT, template< class, class > class Itor = Node_Arc_Iterator, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Path< GT > Aleph::Find_Path_Depth_First< GT, Itor, SA >::operator() ( const GT &  g,
typename GT::Node *  start,
typename GT::Node *  end 
)
inline

Invokes the depth-first path search.

Parameters
[in]gthe graph on which the path is to be searched.
[in]startpointer to the path's starting node.
[in]endpointer to the path's destination node.
Returns
path reaching end if this one was found; false otherwise
Exceptions
bad_allocif there is not enough memory to keep building the path

Definition at line 296 of file tpl_find_path.H.

References Aleph::Find_Path_Depth_First< GT, Itor, SA >::find().

◆ operator()() [4/4]

template<AlephGraph GT, template< class, class > class Itor = Node_Arc_Iterator, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
bool Aleph::Find_Path_Depth_First< GT, Itor, SA >::operator() ( const GT &  g,
typename GT::Node *  start,
typename GT::Node *  end,
Path< GT > &  path 
)
inline

Invokes the depth-first path search.

Parameters
[in]gthe graph on which the path is to be searched.
[in]startpointer to the path's starting node.
[in]endpointer to the path's destination node.
[out]paththe path seen during the depth-first search; empty if the return value is false.
Returns
true if a path from start to end was found.
Exceptions
bad_allocif there is not enough memory to keep building the path

Definition at line 280 of file tpl_find_path.H.

References Aleph::Find_Path_Depth_First< GT, Itor, SA >::find().

◆ remove_last_node()

template<AlephGraph GT, template< class, class > class Itor = Node_Arc_Iterator, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
static void Aleph::Find_Path_Depth_First< GT, Itor, SA >::remove_last_node ( Path< GT > &  path)
inlinestaticprivate

Member Data Documentation

◆ g_ptr

template<AlephGraph GT, template< class, class > class Itor = Node_Arc_Iterator, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
GT* Aleph::Find_Path_Depth_First< GT, Itor, SA >::g_ptr = nullptr
private

◆ sa

template<AlephGraph GT, template< class, class > class Itor = Node_Arc_Iterator, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Kept_Filter<SA> Aleph::Find_Path_Depth_First< GT, Itor, SA >::sa
private

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