Skip to main content

multiplicatively_weighted_harary

Function multiplicatively_weighted_harary 

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

Compute the multiplicatively weighted Harary index.

H_M(G) = Σ_{u<v, dist(u,v)<∞} d(u)·d(v) / dist(u,v)

Disconnected pairs and vertices with degree 0 are skipped.

§Examples

use rust_igraph::{Graph, multiplicatively_weighted_harary};

// Path 0-1-2: d=[1,2,1]
// (0,1): 1×2/1=2, (0,2): 1×1/2=0.5, (1,2): 2×1/1=2
// H_M = 4.5
let g = Graph::from_edges(&[(0,1),(1,2)], false, Some(3)).unwrap();
assert!((multiplicatively_weighted_harary(&g).unwrap() - 4.5).abs() < 1e-10);