// Closeness centrality for every node, normalized to [0, 1]
eles.closenessCentralityNormalized(options?: ClosenessCentralityOptions): AlgoRun<ClosenessCentralityNormalizedResult>Closeness centrality for every node, normalized to [0, 1]. Async: the whole-collection form is the all-pairs tier, so like floydWarshall it returns a promise and executor ('cpu' | 'gpu' | 'workers' | 'auto', default 'auto') picks where it runs; 'cpu' is the reproducible reference. Unweighted runs walk a BFS per source, O(n·(n+E)) — on the worker pool too (one source range per worker, bit-identical to 'cpu'; under 'auto' a sparse graph takes the pool first from 512 nodes, using workers for sparse graphs, and a dense one the GPU first); weighted runs relax Floyd–Warshall, O(n³), and take the offload lane (one pool worker). The single-root closenessCentrality stays synchronous.
Each score is closenessCentrality's for that node (the same harmonic and direction), divided by the largest.
normalization: 'size' divides a harmonic score by n − 1 instead, igraph's and graph-tool's normalized harmonic centrality, and leaves a classic score, which already carries n − 1, as is.
| Name | Description |
|---|---|
options: ClosenessCentralityOptions? |
|
Fields of options
| Name | Description |
|---|---|
root: Collection | null? | |
weight: WeightFn? | |
directed: boolean? | |
direction: 'out' | 'in'? | which distances a directed run sums: |
harmonic: boolean? | Σ 1/d (default, tolerates disconnection), or the classic (n − 1)/Σd with the Wasserman–Faust correction: over the r nodes reachable, (r/Σd)·(r/(n − 1)), 0 when none is |
normalization: 'max' | 'size'? | read by |
executor: AlgoExecutor? | where the run executes; see |
AlgoRun<ClosenessCentralityNormalizedResult>a promise of a closeness accessor — with cancel() on it: a pending run rejects with CancelledError, a 'cpu' run has already completed
Example
const run = eles.closenessCentralityNormalized({ executor: 'cpu' });const result = await run;console.log(result.closeness(cy.getElementById('b')) > 0); // trueif executor, direction or normalization is invalid; rejects if executor: 'gpu' or 'workers' is unavailable in this environment, or 'workers' is asked of a weighted run
Also spelled eles.ccn, eles.closenessCentralityNormalised.