biconnected_components / articulation_points
Computes the biconnected components and articulation points of an undirected graph.
Complexity: O(V + E)
Defined in: <boost/graph/biconnected_components.hpp>
Example
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/biconnected_components.hpp>
#include <iostream>
struct Edge { int comp; };
int main() {
using namespace boost;
using Graph = adjacency_list<vecS, vecS, undirectedS, no_property, Edge>;
Graph g(5);
add_edge(0, 1, g);
add_edge(1, 2, g);
add_edge(2, 0, g); // triangle
add_edge(2, 3, g);
add_edge(3, 4, g);
add_edge(4, 2, g); // second triangle
// Bundled component index written via member-pointer property map.
auto num = biconnected_components(g, get(&Edge::comp, g));
std::cout << "Biconnected components: " << num << "\n";
for (auto ei = edges(g).first; ei != edges(g).second; ++ei) {
std::cout << " " << source(*ei, g) << "-" << target(*ei, g)
<< " component " << g[*ei].comp << "\n";
}
}
Biconnected components: 2
0-1 component 1
1-2 component 1
2-0 component 1
2-3 component 0
3-4 component 0
4-2 component 0
biconnected_components (1)
template <typename Graph, typename ComponentMap, typename OutputIterator,
typename DiscoverTimeMap, typename LowPointMap>
std::pair<std::size_t, OutputIterator>
biconnected_components(
const Graph& g, ComponentMap comp, OutputIterator out,
DiscoverTimeMap discover_time, LowPointMap lowpt);
| Direction | Parameter | Description |
|---|---|---|
IN |
|
An undirected graph. The graph type must be a model of Vertex List Graph and Incidence Graph. |
OUT |
|
The algorithm computes how many biconnected components are in the graph, and assigning each component an integer label. The algorithm then records which component each edge in the graph belongs to by recording the component number in the component property map. The |
OUT |
|
The algorithm writes articulation points via this output iterator and returns the resulting iterator. |
UTIL/OUT |
|
The discovery time of each vertex in the depth-first search. The type |
UTIL/OUT |
|
The low point of each vertex in the depth-first search, which is the smallest vertex reachable from a given vertex with at most one back edge. The type |
biconnected_components (2)
template <typename Graph, typename ComponentMap, typename OutputIterator>
std::pair<std::size_t, OutputIterator>
biconnected_components(
const Graph& g, ComponentMap comp, OutputIterator out);
| Direction | Parameter | Description |
|---|---|---|
IN |
|
An undirected graph. The graph type must be a model of Vertex List Graph and Incidence Graph. |
OUT |
|
The algorithm computes how many biconnected components are in the graph, and assigning each component an integer label. The algorithm then records which component each edge in the graph belongs to by recording the component number in the component property map. The |
OUT |
|
The algorithm writes articulation points via this output iterator and returns the resulting iterator. |
biconnected_components (3)
template <typename Graph, typename ComponentMap>
std::size_t biconnected_components(
const Graph& g, ComponentMap comp);
| Direction | Parameter | Description |
|---|---|---|
IN |
|
An undirected graph. The graph type must be a model of Vertex List Graph and Incidence Graph. |
OUT |
|
The algorithm computes how many biconnected components are in the graph, and assigning each component an integer label. The algorithm then records which component each edge in the graph belongs to by recording the component number in the component property map. The |
biconnected_components (4)
template <typename Graph, typename ComponentMap, typename OutputIterator,
typename P, typename T, typename R>
std::pair<std::size_t, OutputIterator>
biconnected_components(
const Graph& g, ComponentMap comp, OutputIterator out,
const bgl_named_params<P, T, R>& params);
| Direction | Parameter | Description |
|---|---|---|
IN |
|
An undirected graph. The graph type must be a model of Vertex List Graph and Incidence Graph. |
OUT |
|
The algorithm computes how many biconnected components are in the graph, and assigning each component an integer label. The algorithm then records which component each edge in the graph belongs to by recording the component number in the component property map. The |
OUT |
|
The algorithm writes articulation points via this output iterator and returns the resulting iterator. |
- Named Parameters
| Direction | Parameter | Description |
|---|---|---|
IN |
|
This maps each vertex to an integer in the range |
UTIL/OUT |
|
The discovery time of each vertex in the depth-first search. The type |
UTIL/OUT |
|
The low point of each vertex in the depth-first search, which is the smallest vertex reachable from a given vertex with at most one back edge. The type |
UTIL/OUT |
|
The predecessor map records the depth first search tree. The |
IN |
|
A visitor object that is invoked inside the algorithm at the event-points specified by the DFS Visitor concept. The visitor object is passed by value [1]. |
biconnected_components (5)
template <typename Graph, typename ComponentMap,
typename P, typename T, typename R>
std::size_t
biconnected_components(
const Graph& g, ComponentMap comp,
const bgl_named_params<P, T, R>& params);
| Direction | Parameter | Description |
|---|---|---|
IN |
|
An undirected graph. The graph type must be a model of Vertex List Graph and Incidence Graph. |
OUT |
|
The algorithm computes how many biconnected components are in the graph, and assigning each component an integer label. The algorithm then records which component each edge in the graph belongs to by recording the component number in the component property map. The |
- Named Parameters
| Direction | Parameter | Description |
|---|---|---|
IN |
|
This maps each vertex to an integer in the range |
UTIL/OUT |
|
The discovery time of each vertex in the depth-first search. The type |
UTIL/OUT |
|
The low point of each vertex in the depth-first search, which is the smallest vertex reachable from a given vertex with at most one back edge. The type |
UTIL/OUT |
|
The predecessor map records the depth first search tree. The |
IN |
|
A visitor object that is invoked inside the algorithm at the event-points specified by the DFS Visitor concept. The visitor object is passed by value [1]. |
articulation_points (1)
template <typename Graph, typename OutputIterator>
OutputIterator articulation_points(
const Graph& g, OutputIterator out);
| Direction | Parameter | Description |
|---|---|---|
IN |
|
An undirected graph. The graph type must be a model of Vertex List Graph and Incidence Graph. |
OUT |
|
The algorithm writes articulation points via this output iterator and returns the resulting iterator. |
articulation_points (2)
template <typename Graph, typename OutputIterator,
typename P, typename T, typename R>
OutputIterator articulation_points(
const Graph& g, OutputIterator out,
const bgl_named_params<P, T, R>& params);
| Direction | Parameter | Description |
|---|---|---|
IN |
|
An undirected graph. The graph type must be a model of Vertex List Graph and Incidence Graph. |
OUT |
|
The algorithm writes articulation points via this output iterator and returns the resulting iterator. |
- Named Parameters
| Direction | Parameter | Description |
|---|---|---|
IN |
|
This maps each vertex to an integer in the range |
UTIL/OUT |
|
The discovery time of each vertex in the depth-first search. The type |
UTIL/OUT |
|
The low point of each vertex in the depth-first search, which is the smallest vertex reachable from a given vertex with at most one back edge. The type |
UTIL/OUT |
|
The predecessor map records the depth first search tree. The |
IN |
|
A visitor object that is invoked inside the algorithm at the event-points specified by the DFS Visitor concept. The visitor object is passed by value [1]. |
Description
A connected graph is biconnected if the removal of any single vertex (and all edges incident on that vertex) can not disconnect the graph. More generally, the biconnected components of a graph are the maximal subsets of vertices such that the removal of a vertex from a particular component will not disconnect the component. Unlike connected components, vertices may belong to multiple biconnected components: those vertices that belong to more than one biconnected component are called articulation points or, equivalently, cut vertices. Articulation points are vertices whose removal would increase the number of connected components in the graph. Thus, a graph without articulation points is biconnected. The following figure illustrates the articulation points and biconnected components of a small graph:
Vertices can be present in multiple biconnected components, but each edge can only be contained in a single biconnected component. The output of the biconnected_components algorithm records the biconnected component number of each edge in the property map comp. Articulation points will be emitted to the (optional) output iterator argument to biconnected_components, or can be computed without the use of a biconnected component number map via articulation_points. These functions return the number of biconnected components, the articulation point output iterator, or a pair of these quantities, depending on what information was recorded.
The algorithm implemented is due to Tarjan [36].
Returns
Depending on the overload:
-
biconnected_componentsoverloads returningstd::pair<std::size_t, OutputIterator>return the number of biconnected components and the output iterator past the last articulation point written. -
biconnected_componentsoverloads returningstd::size_treturn the number of biconnected components. -
articulation_pointsoverloads return theOutputIteratorpast the last articulation point written.