Skip to main content

is_minimal_separator

Function is_minimal_separator 

Source
pub fn is_minimal_separator(
    graph: &Graph,
    candidates: &[VertexId],
) -> IgraphResult<bool>
Expand description

Check whether a set of vertices is a minimal separator.

A separator is minimal if no proper subset is also a separator. Equivalently, S is a minimal separator if it is a separator and for every vertex v in S, removing S \ {v} does NOT disconnect the graph.

§Errors

  • InvalidArgument if the graph is directed.
  • InvalidArgument if any vertex ID is out of range.

§Examples

use rust_igraph::{Graph, is_minimal_separator};

// 4-cycle: {1,3} is a minimal separator (removing both disconnects 0 from 2).
let mut g = Graph::with_vertices(4);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 3).unwrap();
g.add_edge(3, 0).unwrap();
assert!(is_minimal_separator(&g, &[1, 3]).unwrap());
// {0,1,3} leaves only vertex 2 — not a separator, hence not minimal.
assert!(!is_minimal_separator(&g, &[0, 1, 3]).unwrap());