Skip to main content

randic_index

Function randic_index 

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

Compute the Randić connectivity index.

R(G) = Σ_{(u,v)∈E} 1/√(deg(u)·deg(v))

Isolated vertices and self-loops are ignored.

§Examples

use rust_igraph::{Graph, randic_index};

// Path 0-1-2: 1/√(1·2) + 1/√(2·1) = 2/√2 ≈ 1.414
let g = Graph::from_edges(&[(0,1),(1,2)], false, Some(3)).unwrap();
let r = randic_index(&g).unwrap();
assert!((r - std::f64::consts::SQRT_2).abs() < 1e-10);