Skip to main content

reduced_second_zagreb

Function reduced_second_zagreb 

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

Compute the reduced second Zagreb index.

RM₂(G) = Σ_{(u,v)∈E} (d_u − 1)(d_v − 1)

Self-loops are skipped. Pendant edges (where one endpoint has degree 1) contribute 0.

§Examples

use rust_igraph::{Graph, reduced_second_zagreb};

// K_3: all degrees 2 → each edge: (2-1)(2-1)=1, 3 edges → RM₂=3
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
assert!((reduced_second_zagreb(&g).unwrap() - 3.0).abs() < 1e-10);