Skip to main content

first_zagreb_connection

Function first_zagreb_connection 

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

Compute the first Zagreb connection index.

ZC₁(G) = Σ_{v∈V} τ(v)²

where τ(v) = number of vertices at distance exactly 2 from v.

§Examples

use rust_igraph::{Graph, first_zagreb_connection};

// Path 0-1-2: τ(0)=1, τ(1)=0, τ(2)=1
// ZC₁ = 1+0+1 = 2
let g = Graph::from_edges(&[(0,1),(1,2)], false, Some(3)).unwrap();
assert!((first_zagreb_connection(&g).unwrap() - 2.0).abs() < 1e-10);