Skip to main content

sombor_index

Function sombor_index 

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

Compute the Sombor index.

SO(G) = Σ_{(u,v)∈E} √(d(u)² + d(v)²)

Self-loops are skipped.

§Examples

use rust_igraph::{Graph, sombor_index};

// K_3: each edge √(4+4) = 2√2, 3 edges → 6√2
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
assert!((sombor_index(&g).unwrap() - 6.0 * std::f64::consts::SQRT_2).abs() < 1e-10);