Skip to main content

first_zagreb_coindex

Function first_zagreb_coindex 

Source
pub fn first_zagreb_coindex(graph: &Graph) -> IgraphResult<i64>
Expand description

Compute the first Zagreb coindex.

\bar{M}_1(G) = Σ_{(u,v)∉E, u≠v} (d(u) + d(v))

Uses the identity: \bar{M}_1 = 2m(n-1) - M_1 where M_1 = Σ_v d(v)².

§Examples

use rust_igraph::{Graph, first_zagreb_coindex};

// Path 0-1-2: M₁ = 1+4+1 = 6, m=2, n=3
// bar_M₁ = 2·2·2 - 6 = 2
let g = Graph::from_edges(&[(0,1),(1,2)], false, Some(3)).unwrap();
assert_eq!(first_zagreb_coindex(&g).unwrap(), 2);