Skip to main content

square_clustering_ratio

Function square_clustering_ratio 

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

Compute the square clustering ratio.

Average over all vertices of the fraction of pairs of neighbors that share a second common neighbor (forming a 4-cycle through v). For vertex v with neighbors N(v), counts pairs (a,b) in N(v) that have a common neighbor w != v, divided by total pairs. Returns 0.0 for graphs where no vertex has degree >= 2.

§Examples

use rust_igraph::{Graph, square_clustering_ratio};

// K_4: every pair of neighbors shares 1 other common neighbor → 1.0
let g = Graph::from_edges(
    &[(0,1),(0,2),(0,3),(1,2),(1,3),(2,3)], false, Some(4)
).unwrap();
assert!((square_clustering_ratio(&g).unwrap() - 1.0).abs() < 1e-10);