Skip to main content

st_edge_connectivity

Function st_edge_connectivity 

Source
pub fn st_edge_connectivity(
    graph: &Graph,
    source: VertexId,
    target: VertexId,
) -> IgraphResult<i64>
Expand description

Edge connectivity between two vertices: the minimum number of edges whose removal disconnects source from target.

Counterpart of igraph_st_edge_connectivity in references/igraph/src/flow/flow.c:2219. By the max-flow / min-cut theorem with unit capacities this equals max_flow_value(g, s, t, None) (cast to an integer). This function exists for naming parity with igraph C and to give call sites a typed integer answer when the caller wants the connectivity interpretation rather than the flow one.

§Arguments

  • graph — input graph (directed or undirected). For undirected graphs both arc directions are open, matching igraph C.
  • source — source vertex id (0 ≤ source < vcount()).
  • target — sink vertex id (0 ≤ target < vcount(), target != source).

§Returns

The number of edges in a minimum source → target edge cut as i64. Returns 0 when no source → target path exists (the empty cut already disconnects them).

§Errors

Same as max_flow_value:

§Examples

use rust_igraph::{Graph, st_edge_connectivity};

// Two parallel unit-cap paths 0→1→3 and 0→2→3 → connectivity = 2.
let mut g = Graph::new(4, true).unwrap();
g.add_edge(0, 1).unwrap();
g.add_edge(1, 3).unwrap();
g.add_edge(0, 2).unwrap();
g.add_edge(2, 3).unwrap();
assert_eq!(st_edge_connectivity(&g, 0, 3).unwrap(), 2);