Skip to main content

avg_local_clustering

Function avg_local_clustering 

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

Compute the average local clustering coefficient.

The mean of the local clustering coefficients over all vertices with degree >= 2. The local clustering coefficient of vertex v is the fraction of pairs of neighbors of v that are themselves connected. Returns 0.0 for graphs where no vertex has degree >= 2.

§Examples

use rust_igraph::{Graph, avg_local_clustering};

// K_3: each vertex has 2 neighbors, 1 pair, 1 edge → C(v)=1 → avg=1.0
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
assert!((avg_local_clustering(&g).unwrap() - 1.0).abs() < 1e-10);