Skip to main content

ecc

Function ecc 

Source
pub fn ecc(
    graph: &Graph,
    eids: Option<&[u32]>,
    k: u32,
    offset: bool,
    normalize: bool,
) -> IgraphResult<Vec<f64>>
Expand description

Compute the edge clustering coefficient for eids in graph.

  • eids = None → every edge (in id order, 0..graph.ecount()).
  • eids = Some(&[...]) → just those edges, in the order given.

k must be 3 or 4. offset = true adds the canonical Radicchi +1 to the cycle count; normalize = true divides by the degree-derived maximum.

Edge directions are ignored — the function treats the input as the underlying undirected graph, the same way igraph_ecc does.

§Errors

§Examples

use rust_igraph::{Graph, ecc};

// K_4: every edge sits in 2 triangles, max is 2 → normalised value
// (without offset) is 1.0.
let mut g = Graph::with_vertices(4);
for u in 0..4u32 {
    for v in (u + 1)..4 {
        g.add_edge(u, v).unwrap();
    }
}
let c = ecc(&g, None, 3, false, true).unwrap();
assert_eq!(c, vec![1.0; 6]);