pub fn is_cubic(graph: &Graph) -> IgraphResult<bool>Expand description
Check whether a graph is cubic (3-regular).
A graph is cubic if every vertex has degree exactly 3.
Returns false for directed graphs, empty graphs, or graphs
with fewer than 4 vertices (need at least 4 vertices for a
cubic graph).
ยงExamples
use rust_igraph::{Graph, is_cubic};
// `K_4` is cubic: each vertex has degree 3
let mut g = Graph::with_vertices(4);
for i in 0..4u32 {
for j in (i+1)..4 {
g.add_edge(i, j).unwrap();
}
}
assert!(is_cubic(&g).unwrap());
// `C_4` is 2-regular, not cubic
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_cubic(&g).unwrap());