|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Build a mapped subgraph from a graph starting at a given node. More...
#include <tpl_components.H>
Classes | |
| struct | Arc_Frame |
| struct | Map_Frame |
Public Member Functions | |
| Build_Subgraph (SA arc_filter=SA()) | |
| Construct a subgraph builder with optional arc filter. | |
| void | operator() (const GT &g, GT &sg, typename GT::Node *g_src) |
| Build a mapped subgraph starting from a specific node. | |
| GT | operator() (const GT &g, typename GT::Node *src) |
| Build and return a subgraph containing all nodes reachable from src. | |
| void | operator() (const GT &g, DynList< typename GT::Node * > &list, typename GT::Node *src) |
| Build a list of all nodes reachable from a source node. | |
Private Member Functions | |
| GT::Node * | visit (GT &sg, typename GT::Node *p) |
| GT::Node * | next_to_visit (GT &sg, Map_Frame &f) |
| GT::Node * | visit_through (GT &sg, Map_Frame &f, typename GT::Node *g_tgt) |
| void | build_subgraph (GT &sg, typename GT::Node *g_src) |
| template<template< class > class List> | |
| void | build_subgraph (List< typename GT::Node * > &l, typename GT::Node *p) |
Static Private Member Functions | |
| static void | copy_arc (GT &sg, typename GT::Arc *arc, typename GT::Node *sg_src, typename GT::Node *sg_tgt) |
Private Attributes | |
| SA | sa |
| const GT * | gptr = nullptr |
| size_t | count = 0 |
Build a mapped subgraph from a graph starting at a given node.
This class performs a depth-first traversal of graph g starting from a source node and constructs a mapped copy of all reachable nodes and arcs (the entire graph if connected, or a connected component if not).
The resulting subgraph maintains bidirectional mappings via cookies between the original graph elements and their copies in the subgraph.
Build_Subtree control bit on nodes and arcs, which takes a node or an arc for visited: the bits must be clear, as g.reset_nodes() and g.reset_arcs() leave them, except those of the components built before, as in Unconnected_Components. g had are not read: after the build each node and arc reached maps to its copy, and the copy to it.| GT | Graph type (must satisfy Aleph graph concept). |
| SA | Arc filter type (default: Dft_Show_Arc<GT>). |
Definition at line 113 of file tpl_components.H.
|
inline |
Construct a subgraph builder with optional arc filter.
| arc_filter | Arc filter to control which arcs are traversed (default: show all arcs). |
Definition at line 126 of file tpl_components.H.
|
inlineprivate |
Definition at line 212 of file tpl_components.H.
References Aleph::Build_Subtree, Aleph::Dfs_Stack< T >::is_empty(), IS_NODE_VISITED, Aleph::Build_Subgraph< GT, SA >::Map_Frame::next_arc(), Aleph::Build_Subgraph< GT, SA >::next_to_visit(), Aleph::Dfs_Stack< T >::pop(), Aleph::Dfs_Stack< T >::push(), Aleph::Build_Subgraph< GT, SA >::sa, Aleph::Dfs_Stack< T >::top(), Aleph::Build_Subgraph< GT, SA >::visit(), and Aleph::Build_Subgraph< GT, SA >::visit_through().
Referenced by Aleph::Build_Subgraph< GT, SA >::operator()(), and Aleph::Build_Subgraph< GT, SA >::operator()().
|
inlineprivate |
Definition at line 291 of file tpl_components.H.
References Aleph::DynList< T >::append(), Aleph::Build_Subtree, Aleph::Build_Subgraph< GT, SA >::count, GraphCommon< GT, Node, Arc >::get_num_nodes(), Aleph::Build_Subgraph< GT, SA >::gptr, Aleph::Dfs_Stack< T >::is_empty(), IS_NODE_VISITED, l, Aleph::Build_Subgraph< GT, SA >::Arc_Frame::next_arc(), Aleph::Build_Subgraph< GT, SA >::Arc_Frame::next_target(), NODE_BITS, Aleph::Dfs_Stack< T >::pop(), Aleph::Dfs_Stack< T >::push(), Aleph::Build_Subgraph< GT, SA >::sa, Aleph::Dfs_Stack< T >::top(), and Aleph::Build_Subgraph< GT, SA >::visit().
|
inlinestaticprivate |
Definition at line 163 of file tpl_components.H.
References ARC_COOKIE, GTArcCommon< ArcInfo >::get_info(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_arc(), and GraphCommon< GT, Node, Arc >::map_arcs().
Referenced by Aleph::Build_Subgraph< GT, SA >::next_to_visit(), and Aleph::Build_Subgraph< GT, SA >::visit_through().
|
inlineprivate |
Definition at line 176 of file tpl_components.H.
References ARC_BITS, Aleph::Build_Subtree, Aleph::Build_Subgraph< GT, SA >::copy_arc(), IS_ARC_VISITED, IS_NODE_VISITED, Aleph::Build_Subgraph< GT, SA >::Map_Frame::it, Aleph::Build_Subgraph< GT, SA >::Map_Frame::next_arc(), and Aleph::Build_Subgraph< GT, SA >::Map_Frame::sg_src.
Referenced by Aleph::Build_Subgraph< GT, SA >::build_subgraph().
|
inline |
Build a list of all nodes reachable from a source node.
Performs DFS from src and collects all reachable nodes into list.
| [in] | g | Source graph to traverse. |
| [out] | list | Output list to store reachable node pointers. |
| [in] | src | Starting node for the traversal. |
| std::bad_alloc | If memory allocation fails. |
| std::invalid_argument | If src is nullptr. |
Build_Subtree control bit on nodes and arcs. Definition at line 400 of file tpl_components.H.
References ah_invalid_argument_if, Aleph::Build_Subgraph< GT, SA >::count, and Aleph::Build_Subgraph< GT, SA >::gptr.
|
inline |
Build a mapped subgraph starting from a specific node.
Performs a DFS traversal from g_src and constructs a mapped copy of all reachable nodes and arcs in sg.
| [in] | g | Source graph to traverse. |
| [out] | sg | Output subgraph (should be empty; will contain mapped copy). |
| [in] | g_src | Starting node for the traversal. |
| std::bad_alloc | If memory allocation fails. |
| std::invalid_argument | If g_src is nullptr. |
Build_Subtree control bit on nodes and arcs. sg are mapped to g via cookies. Definition at line 355 of file tpl_components.H.
References ah_invalid_argument_if, Aleph::Build_Subgraph< GT, SA >::build_subgraph(), Aleph::Build_Subgraph< GT, SA >::count, and Aleph::Build_Subgraph< GT, SA >::gptr.
|
inline |
Build and return a subgraph containing all nodes reachable from src.
| [in] | g | Source graph to traverse. |
| [in] | src | Starting node for the traversal. |
| std::bad_alloc | If memory allocation fails. |
| std::invalid_argument | If src is nullptr. |
Definition at line 375 of file tpl_components.H.
References ah_invalid_argument_if, Aleph::Build_Subgraph< GT, SA >::build_subgraph(), Aleph::Build_Subgraph< GT, SA >::count, and Aleph::Build_Subgraph< GT, SA >::gptr.
|
inlineprivate |
Definition at line 150 of file tpl_components.H.
References Aleph::Build_Subtree, Aleph::Build_Subgraph< GT, SA >::count, GTNodeCommon< NodeInfo >::get_info(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node(), GraphCommon< GT, Node, Arc >::map_nodes(), NODE_BITS, and NODE_COOKIE.
Referenced by Aleph::Build_Subgraph< GT, SA >::build_subgraph(), Aleph::Build_Subgraph< GT, SA >::build_subgraph(), and Aleph::Build_Subgraph< GT, SA >::visit_through().
|
inlineprivate |
Definition at line 202 of file tpl_components.H.
References Aleph::Build_Subgraph< GT, SA >::copy_arc(), Aleph::Build_Subgraph< GT, SA >::Map_Frame::it, Aleph::Build_Subgraph< GT, SA >::Map_Frame::sg_src, and Aleph::Build_Subgraph< GT, SA >::visit().
Referenced by Aleph::Build_Subgraph< GT, SA >::build_subgraph().
|
private |
Definition at line 117 of file tpl_components.H.
Referenced by Aleph::Build_Subgraph< GT, SA >::build_subgraph(), Aleph::Build_Subgraph< GT, SA >::Arc_Frame::next_target(), Aleph::Build_Subgraph< GT, SA >::operator()(), Aleph::Build_Subgraph< GT, SA >::operator()(), Aleph::Build_Subgraph< GT, SA >::operator()(), and Aleph::Build_Subgraph< GT, SA >::visit().
|
private |
Definition at line 116 of file tpl_components.H.
Referenced by Aleph::Build_Subgraph< GT, SA >::build_subgraph(), Aleph::Build_Subgraph< GT, SA >::operator()(), Aleph::Build_Subgraph< GT, SA >::operator()(), and Aleph::Build_Subgraph< GT, SA >::operator()().
|
private |
Definition at line 115 of file tpl_components.H.
Referenced by Aleph::Build_Subgraph< GT, SA >::build_subgraph(), and Aleph::Build_Subgraph< GT, SA >::build_subgraph().