Skip to main content

centralization_closeness_wrapper

Function centralization_closeness_wrapper 

Source
pub fn centralization_closeness_wrapper(
    graph: &Graph,
    normalized: bool,
) -> IgraphResult<CentralizationResult>
Expand description

Closeness centralization: compute per-vertex closeness scores and the graph-level centralization in one call.

Vertices with no reachable neighbors produce NaN scores; if any vertex is unreachable the centralization itself will be NaN (matching igraph C semantics for disconnected graphs).

Counterpart of igraph_centralization_closeness().

ยงExamples

use rust_igraph::{Graph, centralization_closeness_wrapper};

// Star K_{1,4}: normalized closeness centralization = 1.0.
let mut g = Graph::with_vertices(5);
for v in 1..5u32 { g.add_edge(0, v).unwrap(); }
let r = centralization_closeness_wrapper(&g, true).unwrap();
assert!((r.centralization - 1.0).abs() < 1e-9);