Skip to main content

degree_entropy_normalized

Function degree_entropy_normalized 

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

Compute the normalized degree entropy.

H_norm(G) = H(G) / ln(n)

Normalizes the natural-log degree entropy to [0, 1]. Returns 0.0 for graphs with fewer than 2 vertices. A value of 1.0 indicates maximum diversity (all vertices have distinct degrees).

§Examples

use rust_igraph::{Graph, degree_entropy_normalized};

// K_4: all degrees equal → H_norm = 0
let g = Graph::from_edges(
    &[(0,1),(0,2),(0,3),(1,2),(1,3),(2,3)], false, Some(4),
).unwrap();
assert!(degree_entropy_normalized(&g).unwrap().abs() < 1e-10);