graph_tool.topology.label_biconnected_components#

graph_tool.topology.label_biconnected_components(g, eprop=None, vprop=None)[source]#

Label the edges of biconnected components, and the vertices which are articulation points.

An edge property map with the component labels is returned, together a boolean vertex map marking the articulation points, and an histogram of component labels.

Parameters:
gGraph

Graph to be used.

epropEdgePropertyMap (optional, default: None)

Edge property to label the biconnected components.

vpropVertexPropertyMap (optional, default: None)

Vertex property to mark the articulation points. If none is supplied, one is created.

Returns:
bicompEdgePropertyMap

Edge property map with the biconnected component labels.

articulationVertexPropertyMap

Boolean vertex property map which has value 1 for each vertex which is an articulation point, and zero otherwise.

ncint

Number of biconnected components.

Notes

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. Vertices can be present in multiple biconnected components, but each edge can only be contained in a single biconnected component.

The algorithm runs in \(O(V + E)\) time.

Examples

>>> g = gt.random_graph(100, lambda: poisson(2), directed=False)
>>> comp, art, hist = gt.label_biconnected_components(g)
>>> print(comp.a)
[33 33  3 33 33  1  0  5 33 26 33 33 33 33 33 19 33 33 33 33  9 33 12 33
 33 33 22 33 33 33 28 33 33 33 33 33 33 33 33 33 33 33 29 33 33 27 33 33
 25 33 10 33 33 33 31 33 33 33 33 33 33 11 33 13 14 33 33 33 16 33 33 15
 33 33 17 33 33 33 33 33 33 18  7 33 24 32 21 33 33 33  2  6  4 33 33 23
  8 33 30 33 20 33 34]
>>> print(art.a)
[1 0 1 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0
 1 0 1 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 1 1 0 0 0 0 1 0 1
 1 0 0 0 0 0 0 0 1 0 0 1 1 1 1 1 0 0 0 0 0 0 0 1 0 0]
>>> print(hist)
[ 1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1
  1  1  1  1  1  1  1  1  1 69  1]