Skip to main content

edge_connectivity

Function edge_connectivity 

Source
pub fn edge_connectivity(graph: &Graph, checks: bool) -> IgraphResult<i64>
Expand description

Edge connectivity (adhesion) of a graph.

Returns the minimum number of edges that must be removed to disconnect some pair of vertices in graph. Equal to min_{s ≠ t} st_edge_connectivity(s, t).

Counterpart of igraph_edge_connectivity (references/igraph/src/flow/flow.c:2270) and its alias igraph_adhesion (flow.c:2433).

§Arguments

  • graph — input graph (directed or undirected).
  • checks — when true, run the cheap short-circuits described in the module docs before falling back to the fixed-vertex O(V)-flows loop. Recommended for any non-trivial graph; the helpers cost O(V + E) and can replace the whole loop. Equivalent to igraph C’s checks argument.

§Returns

The edge connectivity as i64. Returns:

  • 0 when vcount() ≤ 1, or the graph is disconnected.
  • 1 when there is a vertex with degree 1 (undirected) or min(in, out) = 1 (directed).
  • Otherwise, the result of the fixed-vertex st_edge_connectivity loop from vertex 0.

§Errors

Propagates errors from st_edge_connectivity, connected_components, and strongly_connected_components. In practice these arise only from arithmetic overflow on very large graphs, which is unreachable here.

§Examples

use rust_igraph::{Graph, edge_connectivity};

// Undirected ring on 5 vertices — lambda = 2 (any two non-adjacent
// edges form a min-cut).
let mut g = Graph::new(5, false).unwrap();
for (u, v) in [(0u32, 1u32), (1, 2), (2, 3), (3, 4), (4, 0)] {
    g.add_edge(u, v).unwrap();
}
assert_eq!(edge_connectivity(&g, true).unwrap(), 2);

// Undirected path on 5 vertices — lambda = 1 (any edge is a
// bridge).
let mut p = Graph::new(5, false).unwrap();
for (u, v) in [(0u32, 1u32), (1, 2), (2, 3), (3, 4)] {
    p.add_edge(u, v).unwrap();
}
assert_eq!(edge_connectivity(&p, true).unwrap(), 1);