Skip to main content

centralization_degree_wrapper

Function centralization_degree_wrapper 

Source
pub fn centralization_degree_wrapper(
    graph: &Graph,
    mode: DegreeMode,
    loops: bool,
    normalized: bool,
) -> IgraphResult<CentralizationResult>
Expand description

Degree centralization: compute per-vertex degree scores and the graph-level centralization in one call.

mode selects in-/out-/total degree for directed graphs (ignored for undirected). loops controls whether self-loops are counted.

Counterpart of igraph_centralization_degree().

ยงExamples

use rust_igraph::{Graph, DegreeMode, centralization_degree_wrapper};

// Star K_{1,4}: normalized degree centralization = 1.0.
let mut g = Graph::with_vertices(5);
for v in 1..5u32 { g.add_edge(0, v).unwrap(); }
let r = centralization_degree_wrapper(&g, DegreeMode::All, false, true).unwrap();
assert!((r.centralization - 1.0).abs() < 1e-9);
assert!((r.scores[0] - 4.0).abs() < 1e-9);