Skip to main content

variable_first_zagreb

Function variable_first_zagreb 

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

Compute the variable first Zagreb index.

M₁^{(p)}(G) = Σ_{(u,v)∈E} (du^p + dv^p) for real p.

Generalizes: p=1 → first Zagreb, p=2 → forgotten index. Edges with degree-0 endpoint are skipped when p < 0. Self-loops are skipped.

§Examples

use rust_igraph::{Graph, variable_first_zagreb};

// K_3: 3 edges, d=(2,2), p=1 → 3·(2+2) = 12
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
assert!((variable_first_zagreb(&g, 1.0).unwrap() - 12.0).abs() < 1e-10);