Skip to main content

is_strongly_regular

Function is_strongly_regular 

Source
pub fn is_strongly_regular(
    graph: &Graph,
) -> IgraphResult<Option<StronglyRegularParams>>
Expand description

Check whether a graph is strongly regular.

Returns Some(params) if the graph is strongly regular, None otherwise.

Returns None for directed graphs and non-simple graphs.

Complete graphs and edgeless graphs are considered strongly regular (with degenerate parameters).

ยงExamples

use rust_igraph::{Graph, is_strongly_regular};

// Petersen graph: strongly regular (10, 3, 0, 1)
let mut g = Graph::with_vertices(10);
// Outer cycle
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();
// Inner pentagram
g.add_edge(5, 7).unwrap();
g.add_edge(7, 9).unwrap();
g.add_edge(9, 6).unwrap();
g.add_edge(6, 8).unwrap();
g.add_edge(8, 5).unwrap();
// Spokes
g.add_edge(0, 5).unwrap();
g.add_edge(1, 6).unwrap();
g.add_edge(2, 7).unwrap();
g.add_edge(3, 8).unwrap();
g.add_edge(4, 9).unwrap();
let params = is_strongly_regular(&g).unwrap().unwrap();
assert_eq!(params.n, 10);
assert_eq!(params.k, 3);
assert_eq!(params.lambda, 0);
assert_eq!(params.mu, 1);

// Path P4 is NOT strongly regular (not 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();
assert!(is_strongly_regular(&g).unwrap().is_none());