Skip to main content

closed_triplet_ratio

Function closed_triplet_ratio 

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

Compute the closed triplet ratio (global transitivity).

3 * triangles / connected_triples — the fraction of connected triples that are closed into triangles. This is the standard global clustering coefficient. Returns 0.0 for graphs with no connected triples.

§Examples

use rust_igraph::{Graph, closed_triplet_ratio};

// K_3: 1 triangle, 3 connected triples → 3*1/3 = 1.0
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
assert!((closed_triplet_ratio(&g).unwrap() - 1.0).abs() < 1e-10);