Skip to main content

rich_club_density

Function rich_club_density 

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

Compute the rich club density.

Density of the subgraph induced by the top-25% highest-degree vertices (at least 2 vertices). This measures how interconnected the hubs are. Returns 0.0 for trivial graphs or when fewer than 2 vertices qualify.

§Examples

use rust_igraph::{Graph, rich_club_density};

// K_4: all vertices in top 25% → density = 1.0
let g = Graph::from_edges(
    &[(0,1),(0,2),(0,3),(1,2),(1,3),(2,3)], false, Some(4)
).unwrap();
assert!((rich_club_density(&g).unwrap() - 1.0).abs() < 1e-10);