Skip to main content

centrality_divergence

Function centrality_divergence 

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

Compute the Jensen-Shannon divergence between degree centrality and betweenness centrality distributions.

Both centrality vectors are normalized to probability distributions, then JSD = (KL(P||M) + KL(Q||M)) / 2 where M = (P+Q)/2. Returns a value in [0, ln(2)] (or 0.0 for trivial graphs). Higher values indicate that degree and betweenness rank vertices very differently.

§Examples

use rust_igraph::{Graph, centrality_divergence};

// Star graph: hub has high degree AND high betweenness → low divergence
let g = Graph::from_edges(
    &[(0,1),(0,2),(0,3),(0,4)], false, Some(5)
).unwrap();
let jsd = centrality_divergence(&g).unwrap();
assert!(jsd < 0.3); // relatively low divergence