Returns a set of edges of minimum cardinality that disconnects G.
If source and target nodes are provided, this function returns the set of edges of minimum cardinality that, if removed, would break all paths among source and target in G. If not, it returns a set of edges of minimum cardinality that disconnects G.
Parameters: | G : NetworkX graph s : node
t : node
flow_func : function
|
---|---|
Returns: | cutset : set
|
See also
minimum_st_edge_cut(), minimum_node_cut(), stoer_wagner(), node_connectivity(), edge_connectivity(), maximum_flow(), edmonds_karp(), preflow_push(), shortest_augmenting_path()
Notes
This is a flow based implementation of minimum edge cut. For undirected graphs the algorithm works by finding a ‘small’ dominating set of nodes of G (see algorithm 7 in [R218]) and computing the maximum flow between an arbitrary node in the dominating set and the rest of nodes in it. This is an implementation of algorithm 6 in [R218]. For directed graphs, the algorithm does n calls to the max flow function. It is an implementation of algorithm 8 in [R218].
References
[R218] | (1, 2, 3, 4) Abdol-Hossein Esfahanian. Connectivity Algorithms. http://www.cse.msu.edu/~cse835/Papers/Graph_connectivity_revised.pdf |
Examples
>>> # Platonic icosahedral graph has edge connectivity 5
>>> G = nx.icosahedral_graph()
>>> len(nx.minimum_edge_cut(G))
5
You can use alternative flow algorithms for the underlying maximum flow computation. In dense networks the algorithm shortest_augmenting_path() will usually perform better than the default edmonds_karp(), which is faster for sparse networks with highly skewed degree distributions. Alternative flow functions have to be explicitly imported from the flow package.
>>> from networkx.algorithms.flow import shortest_augmenting_path
>>> len(nx.minimum_edge_cut(G, flow_func=shortest_augmenting_path))
5
If you specify a pair of nodes (source and target) as parameters, this function returns the value of local edge connectivity.
>>> nx.edge_connectivity(G, 3, 7)
5
If you need to perform several local computations among different pairs of nodes on the same graph, it is recommended that you reuse the data structures used in the maximum flow computations. See local_edge_connectivity() for details.