edge_connectivity#
- graph_tool.flow.edge_connectivity(g, source=None, target=None, cut=False)[git][source]#
Compute the edge connectivity of the graph, or between two vertices.
- Parameters:
- g
Graph Graph to be used.
- source
Vertex(optional, default:None) Source vertex. If given,
targetmust be given as well, and the local connectivity between them is computed.- target
Vertex(optional, default:None) Target vertex.
- cut
bool(optional, default:False) If
True, a minimum edge cut is also returned.
- g
- Returns:
- lambda
int The edge connectivity.
- cut
EdgePropertyMap Boolean edge property map marking the edges of a minimum cut. Only returned if
cut == True.
- lambda
See also
vertex_connectivityVertex connectivity
minimum_cutMinimum cut of an undirected graph
minimum_st_cutMinimum s-t cut
disjoint_pathsVertex- or edge-disjoint paths
is_k_edge_connectedTest for k-edge-connectivity
Notes
The local edge connectivity \(\lambda(s,t)\) is the smallest number of edges whose removal leaves no path from \(s\) to \(t\), which is equal to the maximum number of edge-disjoint paths between them, and to the maximum flow with unit capacities. It is computed with the Edmonds-Karp algorithm in time \(O(\lambda(s,t)E)\).
The edge connectivity \(\lambda\) of the graph is the smallest number of edges whose removal disconnects it (strongly, if it is directed). It is computed with the algorithm of [schnorr-bottlenecks-1979], which needs \(\lambda(v_i,v_{i+1})\) only for the consecutive pairs of a cyclic ordering of the vertices (an undirected graph is treated as a directed one with both orientations of every edge), in time \(O(\lambda V E)\). For weighted undirected graphs, the minimum cut is given by
minimum_cut().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
[schnorr-bottlenecks-1979]Claus P. Schnorr, “Bottlenecks and edge connectivity in unsymmetrical networks”, SIAM Journal on Computing 8, 265-274 (1979), DOI: 10.1137/0208019 [sci-hub, @tor]
Examples
>>> g = gt.collection.data["football"] >>> l, c = gt.edge_connectivity(g, cut=True) >>> print(l, c.fa.sum()) 7 7
The cut can be highlighted in a drawing of the network:
>>> ecolor = g.new_ep("string", vals=np.where(c.a, "#e41a1c", "#999999")) >>> ewidth = g.new_ep("double", vals=np.where(c.a, 3, 1)) >>> gt.graph_draw(g, g.vp.pos, vertex_fill_color="#cccccc", ... edge_color=ecolor, edge_pen_width=ewidth, ... output="edge_connectivity-football.pdf") <...>
Minimum edge cut of the network of American college football games, with its edges in red.#