Skip to main content

is_split_graph

Function is_split_graph 

Source
pub fn is_split_graph(graph: &Graph) -> IgraphResult<bool>
Expand description

Check whether a graph is a split graph.

A split graph can partition its vertices into a clique C and an independent set I. Uses the Hammer-Simeone degree-sequence characterization for O(V + E) recognition.

Returns false for directed graphs, multigraphs, or graphs with self-loops (the characterization requires simple undirected graphs).

An empty graph (0 vertices) is a split graph (vacuously). An edgeless graph is a split graph (C = empty, I = all vertices).

ยงExamples

use rust_igraph::{Graph, is_split_graph};

// Path P3 (0-1-2): split as C={1}, I={0,2}
let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
assert!(is_split_graph(&g).unwrap());

// Cycle C5 is NOT a split graph
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, 0).unwrap();
assert!(!is_split_graph(&g).unwrap());