Skip to main content

degree_entropy

Function degree_entropy 

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

Shannon entropy of the degree distribution.

H_degree = -Σ_k p(k) log2(p(k))

where p(k) is the fraction of vertices with degree k. Higher entropy indicates a more heterogeneous degree distribution.

§Examples

use rust_igraph::{Graph, degree_entropy};

// Regular graph (cycle): all degrees equal → entropy = 0
let g = Graph::from_edges(&[(0,1),(1,2),(2,3),(3,0)], false, Some(4)).unwrap();
let h = degree_entropy(&g).unwrap();
assert!(h.abs() < 1e-10);