Skip to main content

first_multiplicative_zagreb

Function first_multiplicative_zagreb 

Source
pub fn first_multiplicative_zagreb(graph: &Graph) -> IgraphResult<f64>
Expand description

Compute the first multiplicative Zagreb index.

Π₁(G) = Π_{v∈V, d(v)≥1} d(v)²

The product of squared degrees over vertices with non-zero degree. Returns 1.0 for the empty graph or edgeless graph.

§Examples

use rust_igraph::{Graph, first_multiplicative_zagreb};

// K_3: degrees [2,2,2] → Π₁ = 4·4·4 = 64
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
assert!((first_multiplicative_zagreb(&g).unwrap() - 64.0).abs() < 1e-10);