Skip to main content

centralization

Function centralization 

Source
pub fn centralization(
    scores: &[f64],
    theoretical_max: f64,
    normalized: bool,
) -> f64
Expand description

Compute the graph-level centralization score from per-vertex scores.

Returns C = n * max(scores) - sum(scores) when normalized is false, or C / theoretical_max when normalized is true.

Returns NaN for empty score vectors.

ยงExamples

use rust_igraph::centralization;

// Star graph degree scores: center=4, leaves=1,1,1,1
let scores = [4.0, 1.0, 1.0, 1.0, 1.0];
let c = centralization(&scores, 12.0, true);
assert!((c - 1.0).abs() < 1e-9);