|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Stateful breadth-first traversal functor. More...
#include <tpl_graph_utils.H>
Public Member Functions | |
| Breadth_First_Traversal (SA __sa=SA()) | |
Construct a traversal functor using the arc filter __sa. | |
| size_t | operator() (const GT &g, Operation op) |
| Traverse starting from the first node of the graph. | |
| size_t | operator() (const GT &g, typename GT::Node *p, Operation &&op=Operation()) |
| Traverse starting from a given node. | |
| size_t | operator() (const GT &g, typename GT::Node *p, Operation &op) |
| Traverse starting from a given node (operation by reference). | |
Private Member Functions | |
| size_t | bft (const GT &g, typename GT::Node *start, Operation &op) |
Private Attributes | |
| SA | sa |
| size_t | count = 0 |
Stateful breadth-first traversal functor.
Traverses a graph in breadth-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.
Breadth_First control bit on all nodes and arcs. Breadth_First control bit on both nodes and arcs.Definition at line 414 of file tpl_graph_utils.H.
|
inline |
Construct a traversal functor using the arc filter __sa.
Definition at line 473 of file tpl_graph_utils.H.
|
inlineprivate |
Definition at line 419 of file tpl_graph_utils.H.
References ARC_BITS, Aleph::Breadth_First, Aleph::Breadth_First_Traversal< GT, Operation, SA >::count, Aleph::DynListQueue< T >::get(), GraphCommon< GT, Node, Arc >::get_num_nodes(), GraphCommon< GT, Node, Arc >::get_src_node(), GraphCommon< GT, Node, Arc >::get_tgt_node(), IS_ARC_VISITED, Aleph::DynListQueue< T >::is_empty(), IS_NODE_VISITED, Aleph::maps(), Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), NODE_BITS, Aleph::DynListQueue< T >::put(), GraphCommon< GT, Node, Arc >::reset_bit_arcs(), GraphCommon< GT, Node, Arc >::reset_bit_nodes(), and Aleph::Breadth_First_Traversal< GT, Operation, SA >::sa.
Referenced by Aleph::Breadth_First_Traversal< GT, Operation, SA >::operator()(), Aleph::Breadth_First_Traversal< GT, Operation, SA >::operator()(), and Aleph::Breadth_First_Traversal< GT, Operation, SA >::operator()().
|
inline |
Traverse starting from the first node of the graph.
Traverses the connected component reachable from g.get_first_node() in breadth-first order.
Side effects:
Breadth_First control bit on all nodes and arcs.Breadth_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 489 of file tpl_graph_utils.H.
References Aleph::Breadth_First_Traversal< GT, Operation, SA >::bft(), and Aleph::List_Graph< _Graph_Node, _Graph_Arc >::get_first_node().
|
inline |
Traverse starting from a given node.
Traverses the connected component reachable from p in breadth-first order.
Side effects:
Breadth_First control bit on all nodes and arcs.Breadth_First control bit on both nodes and arcs.| [in] | g | Graph to traverse. |
| [in] | p | 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 509 of file tpl_graph_utils.H.
References Aleph::Breadth_First_Traversal< GT, Operation, SA >::bft().
|
inline |
Traverse starting from a given node (operation by reference).
Equivalent to the rvalue overload, but takes the operation by reference.
| [in] | g | Graph to traverse. |
| [in] | p | 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 525 of file tpl_graph_utils.H.
References Aleph::Breadth_First_Traversal< GT, Operation, SA >::bft().
|
private |
Definition at line 417 of file tpl_graph_utils.H.
Referenced by Aleph::Breadth_First_Traversal< GT, Operation, SA >::bft().
|
private |
Definition at line 416 of file tpl_graph_utils.H.
Referenced by Aleph::Breadth_First_Traversal< GT, Operation, SA >::bft().