Skip to main content

harmonic_graph_index

Function harmonic_graph_index 

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

Compute the harmonic index.

H(G) = Σ_{(u,v)∈E} 2/(deg(u)+deg(v))

§Examples

use rust_igraph::{Graph, harmonic_graph_index};

// Path 0-1-2: 2/(1+2) + 2/(2+1) = 4/3 ≈ 1.333
let g = Graph::from_edges(&[(0,1),(1,2)], false, Some(3)).unwrap();
let h = harmonic_graph_index(&g).unwrap();
assert!((h - 4.0/3.0).abs() < 1e-10);