pub fn mincut_value(
graph: &Graph,
capacity: Option<&[f64]>,
) -> IgraphResult<f64>Expand description
Global minimum-cut value of a (possibly weighted) graph.
Returns the minimum total capacity of an edge set whose removal disconnects some pair of distinct vertices. For undirected input, equivalent to the global min-cut over weak components; for directed input, over strongly connected components.
Mirrors igraph_mincut_value
(references/igraph/src/flow/flow.c:1692).
§Arguments
graph— input graph (directed or undirected).capacity— optional per-edge capacity vector.Nonemeans every edge has unit capacity (in which case the result equalsedge_connectivity(graph, true) as f64). WhenSome(c),c.len()must equalgraph.ecount()and each entry must be a finite non-negative number — these checks are delegated tomax_flow_value.
§Returns
f64::INFINITYifvcount() ≤ 1(no pair to separate).0.0if the graph is not strongly connected (directed) or not connected (undirected).- Otherwise the minimum value of
max_flow_value(graph, 0, v, capacity)(plusmax_flow_value(graph, v, 0, capacity)for directed) overv ∈ 1..vcount().
§Errors
Propagates errors from max_flow_value — chiefly
IgraphError::InvalidArgument for bad capacity input (length
mismatch, NaN, negative).
§Examples
use rust_igraph::{Graph, mincut_value};
// Undirected ring on 5 vertices, unit caps — global min cut = 2.
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!((mincut_value(&g, None).unwrap() - 2.0).abs() < 1e-12);
// Same ring, weighted: each edge weight 0.5 → min cut = 1.0.
let caps = vec![0.5_f64; 5];
let mc = mincut_value(&g, Some(&caps)).unwrap();
assert!((mc - 1.0).abs() < 1e-12);