AI Glossary / Graphs and symbolic AI / Intermediate
Closeness
Definition
Closeness, or closeness centrality, measures how near a node is to other nodes in a graph according to shortest-path distances. In a connected graph, a common normalized form is the reciprocal of the average distance to all other nodes. Higher values indicate shorter average paths under the chosen graph and distance model.
What it means
A node need not have the most direct neighbors to have high closeness. Its neighbors may connect it efficiently to the rest of the network. The measure captures a position within the whole reachable structure rather than simply counting local connections.
The word near is mathematical here. It can mean a few links, a short travel time, or another specified path length. It does not automatically mean geographically near, influential, trusted, or operationally suitable. The supplied term points to NetworkX closeness centrality, whose handling of direction and disconnected components should be stated whenever results are compared.
How it works
Compute shortest-path distances between the selected node and the relevant reachable nodes. For a connected graph with N nodes, divide N minus 1 by the sum of those distances. The result is the inverse average distance.
For disconnected graphs, NetworkX by default also scales the reachable-node calculation by the fraction of the other graph nodes that are reachable. This reduces the score of nodes in small isolated components. For directed graphs, its function uses incoming distances to the node; reverse the graph if outward reach is the intended question. With an edge-distance attribute, path calculations use those distances rather than simply counting edges. The meaning and completeness of that attribute therefore matter.
Three practical examples
- A team compares potential information collection points using incoming shortest paths in a directed communication model.
- A transport study compares locations using modeled travel distances, while evaluating capacity and actual demand separately.
- A knowledge-graph analysis identifies entities that are only a few permitted relationship steps from many other entities, without claiming that those entities are necessarily more important.
Think of it this way
Think of choosing a meeting place by its average journey length from everyone's starting point. A place can be central without being next door to the largest number of people. The analogy is limited because a graph may omit congestion, unequal demand, accessibility, and directions. Those choices can change which location looks close.
Worked example
Take an undirected path with four nodes: A - B - C - D. All edges have length 1. Distances from A to B, C, and D are 1, 2, and 3, summing to 6. A's normalized closeness is 3 divided by 6, or 0.5. For B, distances to A, C, and D are 1, 1, and 2, summing to 4. Its score is 3 divided by 4, or 0.75. C also scores 0.75, and D scores 0.5.
Now add an isolated node E. The reachable distances among A through D stay unchanged. Under NetworkX's default component scaling, B's score becomes (3 divided by 4) times (3 divided by 4), or 0.5625. A's becomes (3 divided by 4) times 0.5, or 0.375. E receives zero. The change reflects the larger graph with an unreachable node, not longer paths inside the original component.
Illustrative case study
At fictional Cedar Networks, an analyst ranks offices in a directed information-sharing graph. The initial report calls the highest-scoring office the best broadcast point. A reviewer notices that the calculation used incoming distance, which instead describes how easily other offices can reach that office.
The analyst reruns the outward-distance analysis and labels the two questions separately. This fictional case illustrates how a technically correct score can answer the wrong business question. It does not report a real ranking, prove influence, or imply that the same location must be best for receiving and distributing information.
Common misconceptions and mistakes
Closeness is not degree centrality, which counts direct connections, or betweenness, which concerns shortest paths passing through a node. These measures describe different structural features.
Do not compare disconnected-network scores without checking the normalization convention. Do not silently treat a strength or similarity weight as a distance: a stronger connection often means greater ease, whereas a larger distance normally means greater separation. Missing distance attributes can also be interpreted as unit distances by NetworkX, so incomplete edge data can quietly change the model. Finally, shortest paths describe the assumed route criterion, not necessarily how people, goods, or messages actually move.
Business use
Closeness can help generate candidates for service locations, coordination points, or network review. Define direction, node population, edge meaning, and distance units before interpreting the ranking. Compare results with relevant demand and capacity information rather than choosing solely from centrality. Preserve the graph version and normalization settings so changes in a score can be explained as either structural changes, data corrections, or a different analytical convention.
People also ask
Is a high score always better?
Only relative to an objective where short modeled paths are beneficial; centrality is not a universal quality rating.
Does NetworkX use outgoing paths by default?
No. For directed graphs, its documented closeness function uses incoming distances.
Can edge weights be used?
Yes, when supplied as a distance attribute with a meaningful interpretation for shortest paths.
Check your understanding
Why does B's score fall after isolated E is added even though B's reachable paths do not change?
Answer: The default component correction multiplies by the fraction of other nodes that are reachable, which falls from 1 to 3/4.
Related terms
- Shortest Paths
- Harmonic Centrality
- Directed graph
- Edge weight
- Centrality
- shortest path
- degree centrality
- betweenness centrality
- connected component
Learn next
Learn harmonic centrality next and compare its handling of unreachable nodes with the closeness convention here. Then reverse a small directed graph and explain the business question answered by each direction before calculating any rankings.
More in Graphs and symbolic AI
- Clause - A clause, in the logic used by many symbolic AI systems, is a disjunction of literals: statements joined by logical OR, where each statement is an atom or...
- Closed-loop - Closed-loop describes a system in which information about the system's behavior feeds back into decisions that influence its subsequent behavior.
- Closed-world assumption - The closed-world assumption is a reasoning convention that treats relevant facts not established by the knowledge base as false.
- Clutter - Clutter, in tracking and data association, means detections that do not come from the target or targets of interest and instead create nuisance observations.
- co-NP - co-NP, usually written coNP, is the class of decision problems whose complementary problems belong to NP.
- co-NP-complete - A decision problem is co-NP-complete, or coNP-complete, when it belongs to coNP and every problem in coNP can be transformed into it by a polynomial-time...
Sources
Primary source: NetworkX official closeness_centrality documentation, including formulas, direction, component correction, and distance-attribute behavior, https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.centrality.closeness_centrality.html . The path calculation and fictional case are original teaching illustrations.
Previous: Closed-world assumption Next: Closure, stop