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:
- g
Graph Graph to be used.
- k
int Required edge connectivity.
- vprop
VertexPropertyMap(optional, default:None) Vertex property map of value type
int32_tto store the component labels. If not supplied, one is created.
- g
- Returns:
- comp
VertexPropertyMap Vertex property map with the component labels.
- hist
numpy.ndarray Histogram of component labels.
- comp
See also
label_k_edge_subgraphsMaximal k-edge-connected subgraphs
label_bridge_components2-edge-connected components
is_k_edge_connectedTest for k-edge-connectivity
k_componentsK-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 (seelabel_bridge_components()). The paths may leave the component, so that, unlike for the subgraphs returned bylabel_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 (seegomory_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") <...>
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.#