Skip to main content

degree_mixing_entropy

Function degree_mixing_entropy 

Source
pub fn degree_mixing_entropy(graph: &Graph) -> IgraphResult<f64>
Expand description

Compute the degree mixing entropy.

Shannon entropy of the distribution of degree pairs (d_u, d_v) over all edges, normalized by log2(m) where m is the edge count. Higher values indicate more diverse degree mixing. Returns 0.0 for graphs with fewer than 2 edges.

§Examples

use rust_igraph::{Graph, degree_mixing_entropy};

// K_3: all edges have same degree pair (2,2) → entropy = 0
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
assert!(degree_mixing_entropy(&g).unwrap().abs() < 1e-10);