Skip to content

eles.betweennessCentrality(options?)

eles.betweennessCentrality — Collection > Algorithms > Centrality. Cytoscape.js signatures, parameters and return contract.

eles.betweennessCentrality — Collection › Algorithms › Centrality

Preview · Collection › Algorithms › Centrality

Read in the complete API reference · All API members

// 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.

Parameters
NameDescription
options: BetweennessCentralityOptions?

{ weight, directed, normalization, executor }

Fields of options
NameDescription
weight: WeightFn | null?
directed: boolean?
normalization: 'max' | 'size'?

how betweennessNormalized scales: 'max' (default) divides by the largest score, 'size' by the number of 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 do

executor: AlgoExecutor?

where the run executes; see AlgoExecutor (default 'auto'). Weighted runs have no GPU path: 'auto' uses workers from 128 nodes when available, and an explicit 'gpu' rejects. Unweighted runs prefer a suitable GPU under 'auto', then workers where no adapter fits.

Returns 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); // true

Example graph and handle setup

Throws

if executor or normalization is invalid; rejects if executor: 'gpu' is unavailable or the run is weighted

Also spelled eles.bc.