// Betweenness centrality — how often each node lies on shortest paths between other pairs: the sum over pairs s ≠ v ≠ t of the share of shortest s–t paths through v, each unordered pair counted once when undirected (Freeman's definition, NetworkX's and igraph's unnormalized score)
eles.betweennessCentrality(options?: BetweennessCentralityOptions): AlgoRun<BetweennessCentralityResult>Betweenness centrality — how often each node lies on shortest paths between other pairs: the sum over pairs s ≠ v ≠ t of the share of shortest s–t paths through v, each unordered pair counted once when undirected (Freeman's definition, NetworkX's and igraph's unnormalized score). betweennessNormalized divides by the largest score. Async: returns a promise, and executor ('cpu' | 'gpu' | 'workers' | 'auto', default 'auto') picks where the Brandes sweep runs. Weighted runs have no GPU path: 'auto' takes the worker pool (one source range per worker, f64-tight to 'cpu' and bit-stable across pool sizes) from 128 nodes and an explicit 'gpu' rejects; unweighted runs keep the GPU first under 'auto', then the pool from 256 nodes where no adapter fits.
betweennessNormalized divides by the largest score, or under normalization: 'size' by the pairs a node can sit between — (n − 1)(n − 2)/2 undirected, (n − 1)(n − 2) directed — as NetworkX's normalized=True and igraph's normalized = TRUE.
| Name | Description |
|---|---|
options: BetweennessCentralityOptions? |
|
Fields of options
| Name | Description |
|---|---|
weight: WeightFn | null? | |
directed: boolean? | |
normalization: 'max' | 'size'? | how |
executor: AlgoExecutor? | where the run executes; see |
AlgoRun<BetweennessCentralityResult>a promise of the { betweenness, betweennessNormalized } accessors — with cancel() on it: a pending run rejects with CancelledError, a 'cpu' run has already completed
Example
const run = eles.betweennessCentrality({ executor: 'cpu' });const result = await run;console.log(result.betweenness(cy.getElementById('b')) > 0); // trueif executor or normalization is invalid; rejects if executor: 'gpu' is unavailable or the run is weighted
Also spelled eles.bc.