Skip to main content

third_zagreb_index

Function third_zagreb_index 

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

Compute the third Zagreb index.

M₃(G) = Σ_{(u,v)∈E} |d(u) - d(v)|

Self-loops are skipped.

§Examples

use rust_igraph::{Graph, third_zagreb_index};

// Star S_4 (center=0): edges (0,1)..(0,4), degrees [4,1,1,1,1]
// Each edge: |4-1|=3, 4 edges → M₃ = 12
let g = Graph::from_edges(&[(0,1),(0,2),(0,3),(0,4)], false, Some(5)).unwrap();
assert_eq!(third_zagreb_index(&g).unwrap(), 12);