Skip to main content

all_minimal_st_separators

Function all_minimal_st_separators 

Source
pub fn all_minimal_st_separators(
    graph: &Graph,
) -> IgraphResult<Vec<Vec<VertexId>>>
Expand description

List all vertex sets that are minimal (s,t) separators for some s and t.

A vertex set S is a minimal (s,t) separator if removing S disconnects s from t, and no proper subset of S does the same for that pair.

This function enumerates ALL such sets (for all possible pairs s,t). Note that a returned separator may not be minimal with respect to disconnecting the graph — see the igraph docs for details.

Based on Berry, Bordat & Cogis (1999): “Generating All the Minimal Separators of a Graph”.

Edge directions are ignored (the graph is treated as undirected).

§Examples

use rust_igraph::{Graph, all_minimal_st_separators};

// Path 0-1-2-3-4-1 (pentagon with chord):
// edges: 0-1, 1-2, 2-3, 3-4, 4-1
let mut g = Graph::with_vertices(5);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 3).unwrap();
g.add_edge(3, 4).unwrap();
g.add_edge(4, 1).unwrap();
let seps = all_minimal_st_separators(&g).unwrap();
// Should contain {1}, {2,4}, {1,3}
assert!(seps.iter().any(|s| s == &[1]));
assert!(seps.iter().any(|s| s == &[2, 4]));
assert!(seps.iter().any(|s| s == &[1, 3]));