pub fn st_mincut_value(
graph: &Graph,
source: VertexId,
target: VertexId,
capacity: Option<&[f64]>,
) -> IgraphResult<f64>Expand description
Scalar s-t minimum-cut value (capacity of the minimum edge set
whose removal disconnects source from target).
Counterpart of igraph_st_mincut_value in
references/igraph/src/flow/flow.c:1127. By the max-flow /
min-cut theorem (Ford-Fulkerson, 1956) the value returned equals
max_flow_value; this function
is a thin wrapper that exists for naming parity with igraph C and
to make call sites intent-revealing when the caller wants the
cut interpretation rather than the flow one.
§Arguments
graph— input graph (directed or undirected).source— source vertex id (0 ≤ source < vcount()).target— sink vertex id (0 ≤ target < vcount(),target != source).capacity— optional per-edge capacity in the graph’s edge-id order. WhenNone, each edge contributes unit capacity. WhenSome(c),c.len()must equalgraph.ecount(), and every entry must be finite and≥ 0.
§Returns
The minimum s-t cut capacity as f64. Returns 0.0 when no
source → target path exists in the residual network (the empty
cut already disconnects them).
§Errors
Same as max_flow_value:
IgraphError::VertexOutOfRangeifsourceortargetis outside[0, vcount()).IgraphError::InvalidArgumentifsource == target, the capacity slice length differs fromecount(), or any capacity is negative / non-finite.
§Examples
use rust_igraph::{Graph, st_mincut_value};
// Two parallel paths of capacity 1 each → min s-t cut = 2
// (must cut both bottleneck edges to disconnect 0 from 3).
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();
let cap = vec![1.0, 1.0, 1.0, 1.0];
let cut = st_mincut_value(&g, 0, 3, Some(&cap)).unwrap();
assert!((cut - 2.0).abs() < 1e-12);