Skip to main content

degree_diversity

Function degree_diversity 

Source
pub fn degree_diversity(graph: &Graph) -> IgraphResult<usize>
Expand description

Compute the degree diversity (number of distinct degree values).

Returns the count of distinct degrees in the graph. Regular graphs have diversity 1. Returns 0 for empty graphs.

§Examples

use rust_igraph::{Graph, degree_diversity};

// Paw: degrees {1,2,2,3} → 3 distinct values
let g = Graph::from_edges(&[(0,1),(1,2),(0,2),(2,3)], false, Some(4)).unwrap();
assert_eq!(degree_diversity(&g).unwrap(), 3);