|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Compute a depth-first spanning tree of a graph. More...
#include <tpl_spanning_tree.H>
Public Member Functions | |
| Find_Depth_First_Spanning_Tree (SA arc_filter=SA()) | |
| Construct a DFS spanning tree builder with optional arc filter. | |
| GT::Node * | operator() (GT &g, GT &tree) |
| Build a depth-first spanning tree starting from the first node. | |
| GT::Node * | operator() (GT &g, typename GT::Node *gnode, GT &tree) |
| Build a depth-first spanning tree starting from a specific node. | |
Private Member Functions | |
| bool | build_tree (typename GT::Node *gnode, typename GT::Arc *garc, typename GT::Node *tnode) |
| bool | build_tree (GT &g, typename GT::Node *gnode, GT &tree) |
Private Attributes | |
| SA | sa |
| GT * | gptr = nullptr |
| GT * | tptr = nullptr |
Compute a depth-first spanning tree of a graph.
This class performs a depth-first traversal starting from a specified node and constructs the spanning tree according to the DFS visit order.
A spanning tree is a subgraph that includes all vertices of the original graph connected by the minimum number of edges (V-1 edges for V vertices) without forming any cycles.
Spanning_Tree control bit on nodes and arcs. These bits are reset at the beginning of the algorithm.tree are mapped to their corresponding elements in g via cookies.| GT | Graph type (must satisfy Aleph graph concept). |
| SA | Arc filter type (default: Dft_Show_Arc<GT>). |
Definition at line 111 of file tpl_spanning_tree.H.
|
inline |
Construct a DFS spanning tree builder with optional arc filter.
| arc_filter | Arc filter to control which arcs are traversed (default: show all arcs). |
Definition at line 209 of file tpl_spanning_tree.H.
|
inlineprivate |
Definition at line 163 of file tpl_spanning_tree.H.
References build_tree(), Aleph::clear_graph(), GraphCommon< GT, Node, Arc >::get_num_nodes(), Aleph::Find_Depth_First_Spanning_Tree< GT, SA >::gptr, Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node(), IS_ARC_VISITED, IS_NODE_VISITED, GraphCommon< GT, Node, Arc >::map_nodes(), Aleph::maps(), NODE_BITS, GraphCommon< GT, Node, Arc >::reset_arcs(), GraphCommon< GT, Node, Arc >::reset_nodes(), Aleph::Find_Depth_First_Spanning_Tree< GT, SA >::sa, Aleph::Spanning_Tree, and Aleph::Find_Depth_First_Spanning_Tree< GT, SA >::tptr.
|
inlineprivate |
Definition at line 118 of file tpl_spanning_tree.H.
References ARC_BITS, build_tree(), GraphCommon< GT, Node, Arc >::get_num_arcs(), GraphCommon< GT, Node, Arc >::get_num_nodes(), Aleph::Find_Depth_First_Spanning_Tree< GT, SA >::gptr, Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_arc(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node(), IS_ARC_VISITED, IS_NODE_VISITED, GraphCommon< GT, Node, Arc >::map_arcs(), GraphCommon< GT, Node, Arc >::map_nodes(), Aleph::maps(), NODE_BITS, Aleph::Find_Depth_First_Spanning_Tree< GT, SA >::sa, Aleph::Spanning_Tree, and Aleph::Find_Depth_First_Spanning_Tree< GT, SA >::tptr.
|
inline |
Build a depth-first spanning tree starting from the first node.
Constructs a spanning tree of the graph using depth-first traversal. After execution, tree contains the spanning tree with nodes and arcs mapped to their corresponding elements in g.
| [in] | g | Source graph to compute spanning tree from. |
| [out] | tree | Output graph that will contain the spanning tree. Will be cleared before construction. |
nullptr otherwise.| std::bad_alloc | If memory allocation fails. |
| std::domain_error | If the graph is empty. |
Spanning_Tree control bit on nodes and arcs. Definition at line 229 of file tpl_spanning_tree.H.
References ah_domain_error_if, build_tree(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::get_first_node(), GraphCommon< GT, Node, Arc >::get_num_nodes(), and Aleph::maps().
|
inline |
Build a depth-first spanning tree starting from a specific node.
Constructs a spanning tree of the graph using depth-first traversal starting from the specified source node.
| [in] | g | Source graph to compute spanning tree from. |
| [in] | gnode | Starting node for the DFS traversal. |
| [out] | tree | Output graph that will contain the spanning tree. Will be cleared before construction. |
gnode.| std::bad_alloc | If memory allocation fails. |
| std::invalid_argument | If gnode is nullptr. |
Spanning_Tree control bit on nodes and arcs. Definition at line 258 of file tpl_spanning_tree.H.
References ah_invalid_argument_if, build_tree(), Aleph::maps(), and NODE_COOKIE.
|
private |
Definition at line 114 of file tpl_spanning_tree.H.
Referenced by Aleph::Find_Depth_First_Spanning_Tree< GT, SA >::build_tree(), and Aleph::Find_Depth_First_Spanning_Tree< GT, SA >::build_tree().
|
private |
Definition at line 113 of file tpl_spanning_tree.H.
Referenced by Aleph::Find_Depth_First_Spanning_Tree< GT, SA >::build_tree(), and Aleph::Find_Depth_First_Spanning_Tree< GT, SA >::build_tree().
|
private |
Definition at line 115 of file tpl_spanning_tree.H.
Referenced by Aleph::Find_Depth_First_Spanning_Tree< GT, SA >::build_tree(), and Aleph::Find_Depth_First_Spanning_Tree< GT, SA >::build_tree().