Skip to main content

second_hyper_zagreb_coindex

Function second_hyper_zagreb_coindex 

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

Compute the second hyper-Zagreb coindex.

\bar{HM₂}(G) = Σ_{u<v, (u,v)∉E} [d(u)·d(v)]²

§Examples

use rust_igraph::{Graph, second_hyper_zagreb_coindex};

// K_3: no non-adjacent pairs → 0
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
assert_eq!(second_hyper_zagreb_coindex(&g).unwrap(), 0);

// Path 0-1-2: non-adj (0,2), (1·1)² = 1
let p = Graph::from_edges(&[(0,1),(1,2)], false, Some(3)).unwrap();
assert_eq!(second_hyper_zagreb_coindex(&p).unwrap(), 1);