Skip to main content

total_irregularity

Function total_irregularity 

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

Compute the total irregularity.

irr_t(G) = ½ Σ_{u≠v} |d_u − d_v|

Sums over all unordered vertex pairs, not just edges. For regular graphs the result is 0.

§Examples

use rust_igraph::{Graph, total_irregularity};

// Path 0-1-2: degrees [1,2,1]
// pairs: (0,1)→|1-2|=1, (0,2)→|1-1|=0, (1,2)→|2-1|=1
// irr_t = ½(1+0+1) = 1
let g = Graph::from_edges(&[(0,1),(1,2)], false, Some(3)).unwrap();
assert!((total_irregularity(&g).unwrap() - 1.0).abs() < 1e-10);