// Closeness centrality of one node — how near it is, by shortest path, to the rest of the collection
eles.closenessCentrality(options?: ClosenessCentralityOptions): numberCloseness centrality of one node — how near it is, by shortest path, to the rest of the collection. Harmonic (default): Σ 1/d, an unreachable node contributing 0. harmonic: false: the classic (n − 1)/Σd, and over r reachable nodes the Wasserman–Faust (r/Σd)·(r/(n − 1)) — NetworkX's definition. Directed runs sum distances from the node (direction: 'out', default, as R igraph and graph-tool) or to it ('in', as NetworkX and Neo4j GDS).
| 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 |
numberthe closeness score
Example
console.log(eles.closenessCentrality({ root: cy.getElementById('b') })); // 2if root is not a node of the collection, or direction is neither 'out' nor 'in'
Also spelled eles.cc.