UltipaDocs
Products
Solutions
Resources
Company
Start Free Trial
UltipaDocs
Start Free Trial
  • Introduction
  • Running Algorithms
    • Degree Centrality
    • Closeness Centrality
    • Harmonic Centrality
    • Eccentricity Centrality
    • Betweenness Centrality
    • Bridges
    • Articulation Points
    • Eigenvector Centrality
    • Katz Centrality
    • CELF
    • PageRank
    • ArticleRank
    • TextRank
    • HITS
    • SybilRank
    • Jaccard Similarity
    • Overlap Similarity
    • Cosine Similarity
    • Pearson Correlation Coefficient
    • Euclidean Distance
    • KNN
    • Vector Similarity
    • Bipartite Graph
    • HyperANF
    • Weakly Connected Components (WCC)
    • Strongly Connected Components (SCC)
    • k-Edge Connected Components
    • Local Clustering Coefficient
    • Triangle Count
    • Clique Count
    • k-Core
    • k-Truss
    • p-Cohesion
    • Induced Subgraph
    • Topological Sort
    • Breadth-First Search (BFS)
    • Depth-First Search (DFS)
    • Dijkstra's Shortest Path
    • A* Shortest Path
    • Yen's K-Shortest Paths
    • Shortest Path (BFS)
    • Delta-Stepping SSSP
    • Shortest Path Faster Algorithm (SPFA)
    • All-Pairs Shortest Path (APSP)
    • Minimum Spanning Tree (MST)
    • K-Spanning Tree
    • Steiner Tree
    • Prize-Collecting Steiner Tree (PCST)
    • Minimum Cost Flow
    • Maximum Flow
    • K-Hop Fast
    • Longest Path (DAG)
    • Random Walk
    • Adamic-Adar Index
    • Common Neighbors
    • Preferential Attachment
    • Resource Allocation
    • Total Neighbors
    • Same Community
    • Louvain
    • Leiden
    • Modularity Optimization
    • Label Propagation
    • HANP
    • SLPA
    • k-Means
    • HDBSCAN
    • K-1 Coloring
    • Modularity
    • Conductance
    • Max k-Cut
      • Node2Vec
      • Struc2Vec
      • LINE
      • Fast Random Projection
      • Summary of Graph Embedding
      • Gradient Descent
      • Backpropagation
      • Skip-gram
      • Skip-gram Optimization
  1. Docs
  2. /
  3. Graph Algorithms
  4. /
  5. Centrality

Eccentricity Centrality

Overview

The eccentricity of a node in a graph is the maximum shortest distance from the node to any other reachable nodes in the graph. This measurement, along with other measurements like closeness centrality and graph diameter, can be considered jointly to determine whether a node is literally located at the very center of the graph.

Concepts

Shortest Distance

The shortest distance between two nodes is the number of edges in the shortest path connecting them. Please refer to Closeness Centrality for more details.

Eccentricity

The eccentricity of a node is the maximum shortest-path distance from that node to any other reachable node. For example, if the shortest distances from node A to all other nodes are [1, 2, 3, 1], then A's eccentricity is 3.

Related concepts:

  • Radius: The minimum eccentricity across all nodes in the graph.
  • Diameter: The maximum eccentricity across all nodes in the graph.
  • Center nodes: Nodes whose eccentricity equals the radius — the most central nodes in the graph.

Eccentricity Centrality

The eccentricity centrality score of a node is the inverse of its eccentricity. The formula is:

where x is the target node, y is any node that connects with x along edges (x itself is excluded), d(x,y) is the shortest distance between x and y.

In this graph, the green and red numbers next to each node represent the shortest distances from that node to the green and red nodes, respectively. Eccentricity centrality scores of the green and red nodes are 1/4 = 0.25 and 1/3 = 0.3333 respectively.

Regarding closeness centrality, the green node has score 8/(1+1+1+1+2+3+4+3) = 0.5, the red node has score 8/(3+3+3+2+1+1+2+1) = 0.5. When two nodes share the same closeness centrality score, eccentricity centrality can act as a secondary metric to determine which node is closer to the center.

Considerations

  • The eccentricity centrality score of isolated nodes is 0.

Example Graph

GQL
INSERT (A:user {_id: "A"}), (B:user {_id: "B"}),
       (C:user {_id: "C"}), (D:user {_id: "D"}),
       (E:user {_id: "E"}), (F:user {_id: "F"}),
       (G:user {_id: "G"}), (H:user {_id: "H"}),
       (I:user {_id: "I"}), (J:user {_id: "J"}),
       (A)-[:vote {weight: 1}]->(B), (A)-[:vote {weight: 2}]->(C),
       (A)-[:vote {weight: 3}]->(D), (E)-[:vote {weight: 2}]->(A),
       (E)-[:vote {weight: 1}]->(F), (F)-[:vote {weight: 4}]->(G),
       (F)-[:vote {weight: 1}]->(I), (G)-[:vote {weight: 2}]->(H),
       (H)-[:vote {weight: 1}]->(I)

Parameters

NameTypeDefaultDescription
idsLIST/_ids of nodes to compute (empty = all nodes).
directionSTRINGbothEdge direction: in, out, or both.
weightSTRING or LIST/Numeric edge property for weighted shortest paths.
limitINT-1Limits the number of results returned (-1 = all).
orderSTRING/Sorts the results by eccentricity: asc or desc.

Run Mode

Returns:

ColumnTypeDescription
nodeIdSTRINGNode identifier (_id)
eccentricityFLOATEccentricity (max shortest-path distance from this node)
centralityFLOATCentrality (1/eccentricity, 0 if disconnected)
isCenterINT1 if this node is a center node (min eccentricity in its component), 0 otherwise
componentIdINTConnected component ID (0-based)

Eccentricity centrality for all nodes:

GQL
CALL algo.eccentricity({
  order: "desc"
}) YIELD nodeId, eccentricity, centrality, isCenter

Result:

nodeIdeccentricitycentralityisCenter
E30.33333333333333331
F30.33333333333333331
G40.250
A40.250
I40.250
D50.20
C50.20
B50.20
H50.20
J000

Weighted eccentricity centrality:

GQL
CALL algo.eccentricity({
  ids: ["A", "B"],
  weight: ["weight"]
}) YIELD nodeId, eccentricity, centrality, isCenter

Result:

nodeIdeccentricitycentralityisCenter
A70.142857142857142850
B80.1250

Stream Mode

Returns the same columns as run mode, streamed for memory efficiency.

GQL
CALL algo.eccentricity.stream({
  order: "desc"
}) YIELD nodeId, centrality
FILTER centrality > 0.25
RETURN nodeId, centrality

Result:

nodeIdcentrality
E0.3333333333333333
F0.3333333333333333

Stats Mode

Returns:

ColumnTypeDescription
nodeCountINTTotal number of nodes
radiusFLOATRadius (minimum eccentricity across all components)
diameterFLOATDiameter (maximum eccentricity across all components)
centerCountINTNumber of center nodes
componentCountINTNumber of connected components
GQL
CALL algo.eccentricity.stats() YIELD nodeCount, radius, diameter, centerCount, componentCount

Result:

nodeCountradiusdiametercenterCount
10352

Write Mode

Computes results and writes them back to node properties. The write configuration is passed as a second argument map.

Write parameters:

NameTypeDescription
db.propertySTRING or MAPNode property to write results to. String: writes the centrality column in results to a property. Map: explicit column-to-property mapping (e.g., {centrality: 'gc_score', eccentricity: 'gc_ecc'}).

Writable columns:

ColumnTypeDescription
eccentricityINTEccentricity
centralityFLOATEccentricity centrality score
isCenterINTCenter node flag

Returns:

ColumnTypeDescription
task_idSTRINGTask identifier for tracking via SHOW TASKS
nodesWrittenINTNumber of nodes with properties written
computeTimeMsINTTime spent computing the algorithm (milliseconds)
writeTimeMsINTTime spent writing properties to storage (milliseconds)
GQL
CALL algo.eccentricity.write({}, {
  db: {
    property: "gc_score"
  }
}) YIELD task_id, nodesWritten, computeTimeMs, writeTimeMs