Skip to main content

local_density_ratio

Function local_density_ratio 

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

Compute the local density ratio.

Mean density of ego-networks: for each vertex v with degree ≥ 2, compute the density of the subgraph induced by v’s neighbors (edges among neighbors / possible edges among neighbors). Average over all qualifying vertices. This equals the mean local clustering coefficient. Returns 0.0 for trivial graphs.

§Examples

use rust_igraph::{Graph, local_density_ratio};

// K_4: every vertex's neighborhood is K_3 → 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!((local_density_ratio(&g).unwrap() - 1.0).abs() < 1e-10);