Skip to main content

balaban_j_index

Function balaban_j_index 

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

Compute the Balaban J index of a graph.

J(G) = m / (μ + 1) · Σ_{(u,v)∈E} 1/√(σ_u · σ_v)

Returns 0.0 for graphs with no edges.

§Examples

use rust_igraph::{Graph, balaban_j_index};

// Path 0-1-2: m=2, n=3, c=1, μ=0
// σ_0=3, σ_1=2, σ_2=3
// J = 2/1 · (1/√(3·2) + 1/√(2·3)) = 2 · 2/√6
let g = Graph::from_edges(&[(0,1),(1,2)], false, Some(3)).unwrap();
let j = balaban_j_index(&g).unwrap();
assert!((j - 4.0 / 6.0_f64.sqrt()).abs() < 1e-10);