pub fn vertex_disjoint_paths(
graph: &Graph,
source: VertexId,
target: VertexId,
) -> IgraphResult<i64>Expand description
Maximum number of pairwise internally vertex-disjoint paths from
source to target.
Counterpart of igraph_vertex_disjoint_paths in
references/igraph/src/flow/flow.c:2374. By Menger’s theorem
(1927) on internal-vertex cuts, this equals the s-t vertex
connectivity (under the Ignore convention) plus the count of
direct source → target edges. See
st_vertex_connectivity
for the connectivity-flavoured spelling.
§Arguments
graph— input graph (directed or undirected).source— source vertex id (0 ≤ source < vcount()).target— sink vertex id (0 ≤ target < vcount(),target != source).
§Returns
The maximum number of internally vertex-disjoint source → target
paths as i64, plus the count of direct source → target edges.
Returns 0 when no path exists at all.
§Errors
Same as
st_vertex_connectivity:
IgraphError::VertexOutOfRangeifsourceortargetis outside[0, vcount()).IgraphError::InvalidArgumentifsource == target(igraph C returnsIGRAPH_UNIMPLEMENTEDfor this case; we useInvalidArgumentfor parity with the rest of our flow module), or ifvcount() < 2.IgraphError::Internalif the sumvc + direct_countoverflowsi64(unreachable in practice — both summands are bounded above byecount() ≤ u32::MAX).
§Examples
use rust_igraph::{Graph, vertex_disjoint_paths};
// Two parallel directed paths 0→1→3 and 0→2→3 → 2 vertex-disjoint paths.
let mut g = Graph::new(4, true).unwrap();
for (s, t) in [(0u32, 1u32), (1, 3), (0, 2), (2, 3)] {
g.add_edge(s, t).unwrap();
}
assert_eq!(vertex_disjoint_paths(&g, 0, 3).unwrap(), 2);