pub fn degree_density(graph: &Graph) -> IgraphResult<f64>Expand description
Compute the degree density (normalized second moment of degree).
DD = (⟨d²⟩/⟨d⟩ - 1) / (n - 1)
where ⟨d²⟩ and ⟨d⟩ are the mean of d² and d. For a random
Erdős–Rényi graph, this equals the edge probability p. For
regular graphs, equals (degree) / (n-1). Returns 0.0 for graphs
with fewer than 2 vertices or zero total degree.
§Examples
use rust_igraph::{Graph, degree_density};
// K_3: d=2 for all, ⟨d²⟩=4, ⟨d⟩=2 → (4/2-1)/(3-1) = 1/2 = 0.5
// But density(K_3) = 1.0, so this is different
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
assert!((degree_density(&g).unwrap() - 0.5).abs() < 1e-10);