|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Stateful depth-first traversal functor. More...
#include <tpl_graph_utils.H>
Public Member Functions | |
| Depth_First_Traversal (SA __sa=SA()) | |
Construct a traversal functor using the arc filter __sa. | |
| size_t | operator() (const GT &g, Operation op=Operation()) |
| Traverse starting from the first node of the graph. | |
| size_t | operator() (const GT &g, typename GT::Node *sn, Operation op=Operation()) |
| Traverse starting from a given node. | |
Private Types | |
| using | Frame = Dfs_Arc_Frame< Node_Arc_Iterator< GT, SA > > |
Private Member Functions | |
| bool | enter (typename GT::Node *node, typename GT::Arc *arc) |
| bool | __dft (typename GT::Node *node, typename GT::Arc *arc=nullptr) |
| size_t | dft (const GT &g, typename GT::Node *start_node, Operation &__op) |
Private Attributes | |
| Operation * | op_ptr = nullptr |
| SA | sa |
| size_t | count = 0 |
| const GT * | g_ptr = nullptr |
Stateful depth-first traversal functor.
Traverses a graph in depth-first order, invoking an operation for each discovered node.
Template parameters:
GT: graph typeOperation: visit functorSA: arc filter used by the internal iteratorOperation must provide: bool operator()(const GT& g, typename GT::Node* node, typename GT::Arc* from).
If the operation returns true, traversal stops early.
Depth_First control bit on both nodes and arcs.Definition at line 173 of file tpl_graph_utils.H.
|
private |
Definition at line 182 of file tpl_graph_utils.H.
|
inline |
Construct a traversal functor using the arc filter __sa.
Definition at line 264 of file tpl_graph_utils.H.
|
inlineprivate |
Definition at line 200 of file tpl_graph_utils.H.
References Aleph::Depth_First, Aleph::Depth_First_Traversal< GT, Operation, SA >::enter(), Aleph::Dfs_Stack< T >::is_empty(), IS_NODE_VISITED, Aleph::Dfs_Arc_Frame< It >::it, Aleph::Dfs_Arc_Frame< It >::next_arc(), Aleph::Dfs_Stack< T >::pop(), Aleph::Dfs_Stack< T >::push(), Aleph::Depth_First_Traversal< GT, Operation, SA >::sa, and Aleph::Dfs_Stack< T >::top().
Referenced by Aleph::Depth_First_Traversal< GT, Operation, SA >::dft().
|
inlineprivate |
Definition at line 246 of file tpl_graph_utils.H.
References Aleph::Depth_First_Traversal< GT, Operation, SA >::__dft(), Aleph::Depth_First_Traversal< GT, Operation, SA >::count, Aleph::Depth_First, Aleph::Depth_First_Traversal< GT, Operation, SA >::g_ptr, Aleph::Depth_First_Traversal< GT, Operation, SA >::op_ptr, GraphCommon< GT, Node, Arc >::reset_bit_arcs(), and GraphCommon< GT, Node, Arc >::reset_bit_nodes().
Referenced by Aleph::Depth_First_Traversal< GT, Operation, SA >::operator()(), and Aleph::Depth_First_Traversal< GT, Operation, SA >::operator()().
|
inlineprivate |
Definition at line 186 of file tpl_graph_utils.H.
References Aleph::Depth_First_Traversal< GT, Operation, SA >::count, Aleph::Depth_First, Aleph::Depth_First_Traversal< GT, Operation, SA >::g_ptr, GraphCommon< GT, Node, Arc >::get_num_nodes(), NODE_BITS, and Aleph::Depth_First_Traversal< GT, Operation, SA >::op_ptr.
Referenced by Aleph::Depth_First_Traversal< GT, Operation, SA >::__dft().
|
inline |
Traverse starting from the first node of the graph.
Traverses the connected component reachable from g.get_first_node() in depth-first order.
Side effects:
Depth_First control bit on all nodes and arcs.Depth_First control bit on both nodes and arcs.| [in] | g | Graph to traverse. |
| [in] | op | Visit operation. |
| bad_alloc | If there is not enough memory. |
Definition at line 280 of file tpl_graph_utils.H.
References Aleph::Depth_First_Traversal< GT, Operation, SA >::dft(), and Aleph::List_Graph< _Graph_Node, _Graph_Arc >::get_first_node().
|
inline |
Traverse starting from a given node.
Traverses the connected component reachable from sn in depth-first order.
Side effects:
Depth_First control bit on all nodes and arcs.Depth_First control bit on both nodes and arcs.| [in] | g | Graph to traverse. |
| [in] | sn | Starting node (must be non-null and belong to g). |
| [in] | op | Visit operation. |
| bad_alloc | If there is not enough memory. |
Definition at line 300 of file tpl_graph_utils.H.
References Aleph::Depth_First_Traversal< GT, Operation, SA >::dft().
|
private |
Definition at line 177 of file tpl_graph_utils.H.
Referenced by Aleph::Depth_First_Traversal< GT, Operation, SA >::dft(), and Aleph::Depth_First_Traversal< GT, Operation, SA >::enter().
|
private |
Definition at line 178 of file tpl_graph_utils.H.
Referenced by Aleph::Depth_First_Traversal< GT, Operation, SA >::dft(), and Aleph::Depth_First_Traversal< GT, Operation, SA >::enter().
|
private |
Definition at line 175 of file tpl_graph_utils.H.
Referenced by Aleph::Depth_First_Traversal< GT, Operation, SA >::dft(), and Aleph::Depth_First_Traversal< GT, Operation, SA >::enter().
|
private |
Definition at line 176 of file tpl_graph_utils.H.
Referenced by Aleph::Depth_First_Traversal< GT, Operation, SA >::__dft().