Skip to main content

all_st_cuts

Function all_st_cuts 

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

List all (s,t) edge cuts of a directed graph (Provan-Shier).

§Arguments

  • graph — directed input graph. Undirected graphs are rejected.
  • source — source vertex id.
  • target — target vertex id (must differ from source).

§Errors

§Examples

use rust_igraph::all_st_cuts;
use rust_igraph::Graph;

// Two parallel routes 0 ⇒ 2: 0→1→2 and 0→2 (here a single path 0→1→2).
let mut g = Graph::new(3, true).unwrap();
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
let res = all_st_cuts(&g, 0, 2).unwrap();
// Two cuts: {0} (edge 0) and {0,1} (edge 1).
assert_eq!(res.partition1s, vec![vec![0], vec![0, 1]]);
assert_eq!(res.cuts, vec![vec![0], vec![1]]);