pub fn transitivity_barrat(
graph: &Graph,
weights: &[f64],
) -> IgraphResult<Vec<Option<f64>>>Expand description
Barrat’s weighted local transitivity, per vertex.
For each vertex v, returns
(Σ over triangles (v, u, w) (w(v,u) + w(v,w))) / (s_v * (deg_v - 1)),
where s_v = Σ_{u ∼ v} w(v, u) is v’s strength and deg_v is
v’s simple degree. Returns None for vertices with triples = 0
(degree < 2 or strength 0) — matches upstream’s
IGRAPH_TRANSITIVITY_NAN mode.
Counterpart of igraph_transitivity_barrat() from
references/igraph/src/properties/triangles.c:874. The graph must
be simple (no multi-edges, no self-loops); otherwise this returns
IgraphError::Internal. Edge directions are ignored — directed
graphs are currently rejected (Phase-1 minimal slice).
weights must have length graph.ecount() and contain only finite,
non-negative values.
Reference: Barrat, Barthélemy, Pastor-Satorras, Vespignani (2004), “The architecture of complex weighted networks”, PNAS 101 3747, equation (5).
§Examples
use rust_igraph::{Graph, transitivity_barrat};
// Triangle 0-1-2 with all unit weights — every vertex sees the
// single triangle, so weighted transitivity equals the unweighted
// value of 1.0.
let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 0).unwrap();
let r = transitivity_barrat(&g, &[1.0, 1.0, 1.0]).unwrap();
assert_eq!(r, vec![Some(1.0), Some(1.0), Some(1.0)]);