edge_connectivity

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:
gGraph

Graph to be used.

sourceVertex (optional, default: None)

Source vertex. If given, target must be given as well, and the local connectivity between them is computed.

targetVertex (optional, default: None)

Target vertex.

cutbool (optional, default: False)

If True, a minimum edge cut is also returned.

Returns:
lambdaint

The edge connectivity.

cutEdgePropertyMap

Boolean edge property map marking the edges of a minimum cut. Only returned if cut == True.

See also

vertex_connectivity

Vertex connectivity

minimum_cut

Minimum cut of an undirected graph

minimum_st_cut

Minimum s-t cut

disjoint_paths

Vertex- or edge-disjoint paths

is_k_edge_connected

Test 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")
<...>
../_images/edge_connectivity-football.png

Minimum edge cut of the network of American college football games, with its edges in red.#