pub fn is_regular(graph: &Graph) -> IgraphResult<bool>Expand description
Check whether a graph is regular.
A graph is regular if every vertex has the same degree. For directed graphs, this checks that all out-degrees are equal AND all in-degrees are equal.
An empty graph (0 vertices) is considered regular. A graph with one vertex is regular (degree may be nonzero due to self-loops).
ยงExamples
use rust_igraph::{Graph, is_regular};
// Cycle C4 is 2-regular
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_regular(&g).unwrap());
// Path P3 is not regular (endpoints have degree 1, middle has 2)
let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
assert!(!is_regular(&g).unwrap());