label_k_edge_components

label_k_edge_components#

graph_tool.flow.label_k_edge_components(g, k, vprop=None)[git][source]#

Label the \(k\)-edge-connected components of the graph.

Parameters:
gGraph

Graph to be used.

kint

Required edge connectivity.

vpropVertexPropertyMap (optional, default: None)

Vertex property map of value type int32_t to store the component labels. If not supplied, one is created.

Returns:
compVertexPropertyMap

Vertex property map with the component labels.

histnumpy.ndarray

Histogram of component labels.

See also

label_k_edge_subgraphs

Maximal k-edge-connected subgraphs

label_bridge_components

2-edge-connected components

is_k_edge_connected

Test for k-edge-connectivity

k_components

K-vertex-connected components

Notes

A \(k\)-edge-connected component is a maximal set of vertices in which every pair is joined by \(k\) edge-disjoint paths of the whole graph, i.e. has local edge connectivity \(\lambda(u,v) \ge k\) (see edge_connectivity()); for directed graphs, both \(\lambda(u,v) \ge k\) and \(\lambda(v,u) \ge k\) are required. Since \(\lambda(u,w) \ge \min(\lambda(u,v), \lambda(v,w))\), these sets partition the vertices. For \(k=1\) they are the (strongly) connected components, and for \(k=2\) in undirected graphs the bridge components (see label_bridge_components()). The paths may leave the component, so that, unlike for the subgraphs returned by label_k_edge_subgraphs(), the subgraph induced by a component need not be \(k\)-edge-connected itself. The components of all values of \(k\) of an undirected graph can also be read from its Gomory-Hu tree (see gomory_hu_tree()), as the components that remain after the tree edges of weight below \(k\) are removed.

The components are found by partition refinement within each bridge component (or strongly connected component, if the graph is directed), since no path between two of its vertices leaves it. A vertex of degree below \(k\) is placed alone, and the remaining vertices of a part are tested against its first vertex with maximum flows that stop at \(k\); a flow below \(k\) gives a minimum cut, along which the part is split, so that at most \(2V\) flows are needed, which gives \(O(kVE)\) time. Two speed-ups are used, following [chang-efficiently-2013]: the flows of undirected graphs are computed on a sparse certificate [nagamochi-linear-1992], the union of \(k\) successive maximal spanning forests, which has at most \(k(V-1)\) edges and preserves all local edge connectivities up to \(k\); and a vertex with \(k\) edges to vertices already known to be in the class of the first one needs no flow, since every cut separating it from them contains these edges.

Parallel edges are counted with their multiplicities; self-loops are ignored.

Parallel implementation.

If enabled during compilation, this algorithm will run in parallel using OpenMP. See the parallel algorithms section for information about how to control several aspects of parallelization.

References

[chang-efficiently-2013]

Lijun Chang, Jeffrey Xu Yu, Lu Qin, Xuemin Lin, Chengfei Liu and Weifa Liang, “Efficiently computing k-edge connected components via graph decomposition”, Proceedings of the 2013 ACM SIGMOD International Conference on Management of Data, 205-216 (2013), DOI: 10.1145/2463676.2465323 [sci-hub, @tor]

[nagamochi-linear-1992]

Hiroshi Nagamochi and Toshihide Ibaraki, “A linear-time algorithm for finding a sparse k-connected spanning subgraph of a k-connected graph”, Algorithmica 7, 583-596 (1992), DOI: 10.1007/BF01758778 [sci-hub, @tor]

Examples

>>> g = gt.collection.data["football"]
>>> comp, hist = gt.label_k_edge_components(g, 9)
>>> print(hist[hist > 1])
[111]

In Zachary’s karate club network, the 4-edge-connected component with more than one vertex can be highlighted in a drawing:

>>> g = gt.collection.data["karate"]
>>> comp, hist = gt.label_k_edge_components(g, 4)
>>> vcolor = g.new_vp("string", vals=np.where(hist[comp.a] > 1, "#f28c8e",
...                                           "#cccccc"))
>>> gt.graph_draw(g, g.vp.pos, vertex_fill_color=vcolor,
...               output="label_k_edge_components-karate.pdf")
<...>
../_images/label_k_edge_components-karate.png

4-edge-connected component of Zachary’s karate club network with more than one vertex, in red. The vertices that form components of their own are shown in gray.#