Skip to content

@eightkk/vue-weave / core / graphBetweennessCentrality

Function: graphBetweennessCentrality() ​

graphBetweennessCentrality(nodes, edges, options?): Map<string, number>

Defined in: src/core/graphAnalysis.ts:113

Betweenness centrality by Brandes' algorithm: for every node, the share of shortest paths between other node pairs that pass through it. Cost is O(V·E) without weight and O(V·(E + V) log V) with it, so it suits graphs of a few thousand nodes. Parallel edges count as distinct shortest paths; self-loops never lie on shortest paths. Lengths that differ by less than a relative 1e-12 are treated as equal.

Normalization divides by (n − 1)(n − 2), the number of ordered node pairs excluding the node itself. For undirected graphs the raw score counts each unordered pair once (the ordered sum halved) and the divisor is (n − 1)(n − 2) / 2, which gives the same result as dividing the ordered sum by (n − 1)(n − 2). With fewer than three nodes, normalized scores are 0.

Parameters ​

nodes ​

readonly IdentifiedNode[]

edges ​

readonly GraphEdge<unknown>[]

options? ​

GraphBetweennessOptions = {}

Returns ​

Map<string, number>

Released under the MIT License.