Skip to main content

first_neighborhood_zagreb

Function first_neighborhood_zagreb 

Source
pub fn first_neighborhood_zagreb(graph: &Graph) -> IgraphResult<u64>
Expand description

Compute the first neighborhood Zagreb index.

NM₁(G) = Σ_v S(v)² where S(v) = Σ_{u∈N(v)} d(u).

§Examples

use rust_igraph::{Graph, first_neighborhood_zagreb};

// K_3: each vertex has 2 neighbors of degree 2, S(v)=4
// NM₁ = 3 × 16 = 48
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
assert_eq!(first_neighborhood_zagreb(&g).unwrap(), 48);