Skip to main content

sigma_index

Function sigma_index 

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

Compute the sigma index (Gutman irregularity).

σ(G) = Σ_{(u,v)∈E} (d_u − d_v)²

Self-loops contribute 0. For regular graphs the result is 0.

§Examples

use rust_igraph::{Graph, sigma_index};

// Path 0-1-2: degrees [1,2,1]
// edge(0,1): (1-2)²=1, edge(1,2): (2-1)²=1
// σ = 2
let g = Graph::from_edges(&[(0,1),(1,2)], false, Some(3)).unwrap();
assert!((sigma_index(&g).unwrap() - 2.0).abs() < 1e-10);