Expand description
Centrality — who matters in the graph, five ways. All return a Vec<f32>
indexed by node (0..n). Deterministic; no RNG.
Functions§
- betweenness
- Betweenness centrality (Brandes’ algorithm, undirected, unweighted). The
fraction of shortest paths through each node; normalised by
(n-1)(n-2)so it lands in[0, 1].O(n·m). - closeness
- Closeness centrality (undirected) —
(reachable-1) / Σ dist, scaled by the reachable fraction so nodes in small components aren’t over-rated (Wasserman–Faust).0.0for isolated nodes. BFS from each node (unweighted). - degree
- Degree centrality — undirected degree normalised by
n - 1(the fraction of other nodes a node is adjacent to).0.0forn ≤ 1. - eigenvector
- Eigenvector centrality (undirected) via power iteration for
iterssteps. Iterates(A + I)rather thanA— the identity shift makes every eigenvalue positive, curing the bipartite oscillation that traps plainA·x(a star / path never converges because+λand−λhave equal magnitude). L2-normalised each step.0.0everywhere for an edgeless graph (centrality is undefined there). - in_
out_ degree - In-degree and out-degree centrality (directed), normalised by
n - 1. - pagerank
- PageRank (directed) with damping
d(typically0.85) foriterspower iterations. Dangling nodes (no out-edges) redistribute their mass uniformly. Returns a probability distribution summing to ≈1.