Skip to main content

second_zagreb_index

Function second_zagreb_index 

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

Compute the second Zagreb index M₂(G) = Σ_{(u,v)∈E} deg(u)·deg(v).

§Examples

use rust_igraph::{Graph, second_zagreb_index};

// Path 0-1-2: edge (0,1): 1·2=2, edge (1,2): 2·1=2 → M₂ = 4
let g = Graph::from_edges(&[(0,1),(1,2)], false, Some(3)).unwrap();
assert_eq!(second_zagreb_index(&g).unwrap(), 4);