Skip to main content

is_separator

Function is_separator 

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

Check whether a set of vertices is a separator of the graph.

A vertex set S is a separator if removing S (and all incident edges) makes the remaining graph disconnected, OR if removing S leaves fewer vertices than the original graph minus |S| (i.e., some vertex becomes isolated). For a graph that is already disconnected, any set is technically a separator — this function returns true for the empty set in that case.

For undirected graphs only.

§Errors

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

§Examples

use rust_igraph::{Graph, is_separator};

// Path 0-1-2: removing vertex 1 disconnects the graph.
let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
assert!(is_separator(&g, &[1]).unwrap());
assert!(!is_separator(&g, &[0]).unwrap()); // leaf removal doesn't disconnect