Edd's Knowledge Base

Centrality measures answer the question “which nodes matter most in a network?” Each measure formalizes a different meaning of “important”: having many connections, being close to everyone, sitting on the routes between others, or being connected to other important nodes. There is no single best measure; the right one depends on what flows through the network (information, disease, money, traffic) and what “important” means for the question.

Running Example

A small undirected network of five nodes: a triangle (A, B, C) with a tail (C, D, E).

graph LR
    A((A)) --- B((B))
    A --- C((C))
    B --- C
    C --- D((D))
    D --- E((E))

All values below are for this graph (verified with NetworkX).

NodeDegreeClosenessBetweenness (normalized)
A0.500.570.00
B0.500.570.00
C0.750.800.67
D0.500.670.50
E0.250.440.00

Note how D ties with A and B on degree (2 connections each) but has far higher betweenness: it is the only link between E and the rest. That gap is the point of betweenness.

Degree Centrality

The number of edges at a node, usually divided by the maximum possible ():

  • Meaning: local popularity or immediate reach. Cheap to compute.
  • Directed graphs: split into in-degree (popularity, how many point to you) and out-degree (activity, how many you point to).
  • Limit: ignores the wider structure. A node linked to ten obscure nodes scores the same as one linked to ten hubs.

Example: C has 3 neighbors out of a possible 4, so .

Closeness Centrality

The inverse of a node’s average shortest-path distance to all others:

  • Meaning: how quickly a node can reach everyone, such as how fast news from it spreads.
  • Limit: undefined on disconnected graphs (infinite distances). Harmonic centrality, , fixes this because unreachable nodes contribute zero.

Example: C reaches A, B, D in 1 step and E in 2, so the distance sum is 5 and . E is the farthest: its distance sum is 9, giving .

Betweenness Centrality

The fraction of all shortest paths between other node pairs that pass through a node:

where is the number of shortest paths from to and is how many of them go through . It is usually normalized by the number of node pairs, for undirected graphs, so values fall between 0 and 1.

  • Meaning: brokerage and control over flow. High-betweenness nodes are bridges and bottlenecks: removing them fragments the network or lengthens routes.
  • Same idea for edges: edge betweenness finds the links carrying the most traffic (used in the Girvan-Newman community detection algorithm).
  • Cost: computed exactly with Brandes’ algorithm; on large graphs it is often approximated by sampling source nodes.
  • Weights: with weighted edges, “shortest” means smallest total weight, so edge weights must be distances (costs), not strengths.

Example: C lies on the only shortest paths for A-D, A-E, B-D, B-E, so its raw betweenness is 4; dividing by 6 pairs gives 0.67. D lies on A-E, B-E, and C-E: raw 3, normalized 0.50. A, B, and E sit on no one else’s shortest paths, so their betweenness is 0.

Eigenvector Centrality, Katz, and PageRank

These measures say a node is important if it is connected to important nodes.

  • Eigenvector centrality: a node’s score is proportional to the sum of its neighbors’ scores, . The solution is the leading eigenvector of the adjacency matrix .
  • Katz centrality: counts all walks from a node, discounting longer ones by a factor : . It stays well behaved on directed graphs where eigenvector centrality can collapse to zero.
  • PageRank: Katz-like scoring with a random surfer who follows links with probability (typically 0.85) and jumps to a random node otherwise. Designed for ranking web pages in directed graphs.

Eigenvector centrality in detail

The recursive definition (“important nodes link to important nodes”) resolves into . By the Perron-Frobenius theorem, a connected graph has a single non-negative eigenvector for the largest eigenvalue, and that is the centrality vector. Power iteration finds it: start with equal scores, repeatedly replace each node’s score with the sum of its neighbors’ scores, and rescale until the scores stop changing.

Weakness: in a directed graph, a node with no incoming edges scores 0 and passes nothing on, so everything downstream can collapse to 0.

PageRank in detail

PageRank models a random surfer who follows a random outgoing link with probability (the damping factor, 0.85 by default in NetworkX) and jumps to a random node with probability :

  • A node splits its score among the nodes it links to, so a link from a selective page counts for more than one from a page with many outlinks.
  • The random jump keeps every node’s score above zero and makes the iteration converge.
  • Dangling nodes (no outgoing links) are handled by jumping; NetworkX lets you set this with the dangling argument, and personalization biases the jumps toward chosen nodes.
  • NetworkX uses power iteration and raises PowerIterationFailedConvergence if it does not converge within max_iter (default 100). Undirected graphs are treated as directed with two edges per original edge.

Comparison on the running example

NodeDegreeBetweennessEigenvectorPageRank
A0.500.000.500.19
B0.500.000.500.19
C0.750.670.600.28
D0.500.500.340.21
E0.250.000.160.12

Eigenvector scores are unit-length and PageRank scores sum to 1 (both computed with NetworkX), so compare rankings, not raw values. D ties with A and B on degree but ranks lower on eigenvector centrality because its neighbors (C and E) are weaker than A’s and B’s, while betweenness ranks it higher because it bridges the tail. The two measures answer different questions.

Source: NetworkX: pagerank, citing Page, Brin, Motwani and Winograd (1999).

Choosing a Measure

QuestionMeasure
Who has the most direct contacts?Degree
Who can reach (or spread to) everyone fastest?Closeness or harmonic
Who controls the flow or links separate groups?Betweenness
Who is connected to influential nodes?Eigenvector, Katz, PageRank

The measures often correlate, but the interesting cases are where they disagree: a low-degree, high-betweenness node is a broker, and a high-degree, low-betweenness node sits inside a dense cluster.

Code (NetworkX)

import networkx as nx
 
G = nx.Graph([("A", "B"), ("A", "C"), ("B", "C"), ("C", "D"), ("D", "E")])
 
nx.degree_centrality(G)        # {'C': 0.75, ...}
nx.closeness_centrality(G)     # C: 0.80, E: 0.44
nx.betweenness_centrality(G)   # C: 0.67, D: 0.50, others 0
nx.betweenness_centrality(G, normalized=False)  # C: 4.0, D: 3.0
nx.eigenvector_centrality(G)
nx.pagerank(G, alpha=0.85)

For very large graphs, betweenness_centrality(G, k=100) samples 100 source nodes to approximate the result.

Sources

Verification: the worked-example numbers were computed with NetworkX. Definitions of betweenness and its normalization match the NetworkX docs. The closeness, eigenvector, Katz and PageRank formulas, the harmonic-centrality fix, and the Girvan-Newman remark are standard results written from memory rather than checked against a source. Please check the sources.