|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Compute the connected components of a graph. More...
#include <tpl_components.H>
Public Member Functions | |
| Unconnected_Components (SA arc_filter=SA()) | |
| Construct a component finder with optional arc filter. | |
| template<template< class > class List> | |
| void | compute_blocks (const GT &g, List< GT > &list) |
| Compute connected components as mapped subgraphs. | |
| template<template< class > class List> | |
| void | compute_lists (const GT &g, List< List< typename GT::Node * > > &list) |
| Compute connected components as lists of node pointers. | |
| void | operator() (const GT &g, DynList< GT > &list) |
| Compute connected components as mapped subgraphs. | |
| void | operator() (const GT &g, DynList< DynList< typename GT::Node * > > &list) |
| Compute connected components as lists of node pointers. | |
| size_t | count_components (const GT &g) |
| Count the number of connected components in a graph. | |
| bool | is_connected (const GT &g) |
| Check if a graph is connected. | |
Private Attributes | |
| SA | sa |
Compute the connected components of a graph.
This class takes a graph g (possibly disconnected) and computes all its connected components, storing them as a list of mapped subgraphs or as lists of node pointers.
A connected component is a maximal subgraph in which any two vertices are connected to each other by paths.
Build_Subtree control bit on nodes and arcs.| GT | Graph type (must satisfy Aleph graph concept). |
| SA | Arc filter type (default: Dft_Show_Arc<GT>). |
Definition at line 314 of file tpl_components.H.
|
inline |
Construct a component finder with optional arc filter.
| arc_filter | Arc filter to control which arcs are traversed (default: show all arcs). |
Definition at line 325 of file tpl_components.H.
|
inline |
Compute connected components as mapped subgraphs.
| List | Container template for the output list. |
| [in] | g | Source graph. |
| [out] | list | Output list of subgraphs, one per component. |
| std::bad_alloc | If memory allocation fails. |
Definition at line 337 of file tpl_components.H.
References Aleph::DynList< T >::append(), Aleph::Build_Subtree, Aleph::count(), GraphCommon< GT, Node, Arc >::get_num_nodes(), IS_NODE_VISITED, Aleph::maps(), GraphCommon< GT, Node, Arc >::reset_arcs(), GraphCommon< GT, Node, Arc >::reset_nodes(), and Aleph::Unconnected_Components< GT, SA >::sa.
|
inline |
Compute connected components as lists of node pointers.
| List | Container template for the output lists. |
| [in] | g | Source graph. |
| [out] | list | Output list of node lists, one per component. |
| std::bad_alloc | If memory allocation fails. |
Definition at line 369 of file tpl_components.H.
References Aleph::DynList< T >::append(), Aleph::Build_Subtree, Aleph::count(), GraphCommon< GT, Node, Arc >::get_num_nodes(), IS_NODE_VISITED, l, Aleph::maps(), GraphCommon< GT, Node, Arc >::reset_arcs(), GraphCommon< GT, Node, Arc >::reset_nodes(), Aleph::Unconnected_Components< GT, SA >::sa, and Aleph::HTList::size().
Count the number of connected components in a graph.
| [in] | g | Source graph. |
Definition at line 433 of file tpl_components.H.
References Aleph::maps(), and Aleph::HTList::size().
Referenced by Aleph::Unconnected_Components< GT, SA >::is_connected().
Check if a graph is connected.
| [in] | g | Source graph. |
true if the graph has exactly one connected component (or is empty), false otherwise. Definition at line 447 of file tpl_components.H.
References Aleph::Unconnected_Components< GT, SA >::count_components(), and GraphCommon< GT, Node, Arc >::get_num_nodes().
|
inline |
Compute connected components as lists of node pointers.
Finds all connected components and stores each as a list of pointers to the original nodes in g.
| [in] | g | Source graph. |
| [out] | list | Output list of node lists, one per component. |
| std::bad_alloc | If memory allocation fails. |
Build_Subtree control bit on nodes and arcs. Definition at line 422 of file tpl_components.H.
References Aleph::maps().
|
inline |
Compute connected components as mapped subgraphs.
Finds all connected components in the graph and stores each as a separate mapped subgraph in the output list.
| [in] | g | Source graph. |
| [out] | list | Output list of subgraphs, one per component. Each subgraph is mapped to g via cookies. |
| std::bad_alloc | If memory allocation fails. |
Build_Subtree control bit on nodes and arcs. Definition at line 405 of file tpl_components.H.
References Aleph::maps().
|
private |
Definition at line 316 of file tpl_components.H.
Referenced by Aleph::Unconnected_Components< GT, SA >::compute_blocks(), and Aleph::Unconnected_Components< GT, SA >::compute_lists().