Skip to main content

triangle_participation

Function triangle_participation 

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

Compute the triangle participation ratio.

Fraction of vertices that participate in at least one triangle. Returns 0.0 for graphs with fewer than 3 vertices or no edges.

§Examples

use rust_igraph::{Graph, triangle_participation};

// K_3: all 3 vertices in a triangle → 1.0
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
assert!((triangle_participation(&g).unwrap() - 1.0).abs() < 1e-10);