Skip to main content

second_neighborhood_zagreb

Function second_neighborhood_zagreb 

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

Compute the second neighborhood Zagreb index.

NM₂(G) = Σ_{(u,v)∈E} S(u) · S(v)

Self-loops are skipped.

§Examples

use rust_igraph::{Graph, second_neighborhood_zagreb};

// K_3: S(v)=4 for all v, 3 edges → 3 × 16 = 48
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
assert_eq!(second_neighborhood_zagreb(&g).unwrap(), 48);