Guest
Sign in to keep your graphs and progress.

Practice book
Graph Theory Through Problems300 Exercises with Hints, Worked Algorithms and Complete Solutions
By Mohammed Islam Hadjoudj
Learn graph theory by solving problems: 300 exercises, from routine checks to challenging proofs, each with a complete solution.
Also by the authorGraph Algorithms for Coding Interviews100 solved interview problems with visual explanations and Python solutions.View on AmazonSelect an algorithm and generate steps to begin visualization
Important neighbours make you important
Power iteration: every vertex repeatedly takes the sum of its neighbours' scores, so a vertex is central when its neighbours are
Select an algorithm and generate steps to begin visualization
Eigenvector centrality scores a vertex by the importance of its neighbours, not just by how many it has. A vertex linked to several central vertices ranks high even with few edges, while a vertex with many unimportant neighbours ranks lower. Formally the scores are the entries of the leading eigenvector of the adjacency matrix A: each score is proportional to the sum of the neighbours' scores, x = (1/λ) A x, with λ the largest eigenvalue. By the Perron-Frobenius theorem this vector is unique and positive on a connected graph. Phillip Bonacich proposed it for social networks in 1972, and PageRank and Katz centrality are variants of the same idea.
The visualizer computes the eigenvector by power iteration. Every vertex starts with the same score. In each round every vertex adds up the scores of its neighbours (weighted by the edges if the graph is weighted), and the whole vector is then divided by its length so the numbers stay small. Repeated multiplication by A amplifies the leading eigenvector and suppresses all others, so the scores converge, usually within a few dozen rounds. Each round here uses A + I, adding the vertex's own score: this has the same eigenvectors but stops the scores from oscillating on bipartite graphs, as in NetworkX. The run stops when no score changes by more than 0.0001. The first round is shown vertex by vertex, then one step per round.
Eigenvector centrality identifies influential people in social networks, key actors in organizations and criminal networks, and important proteins and genes in biological networks. It is the basis of link-analysis rankings: Google's PageRank adds a random jump to it so that it works on directed web graphs, and HITS splits it into hub and authority scores. In economics it ranks sectors in input-output networks, in neuroscience brain regions in connectomes. On directed graphs use PageRank or HITS instead, since eigenvector centrality can collapse to zero on graphs without cycles.
Power iteration finds the leading eigenvector without computing any of the others: multiply by the matrix, rescale, repeat.
EigenvectorCentrality(G, tol = 0.0001):
x[v] = 1 / √n for every vertex v
repeat:
for each vertex v:
y[v] = x[v] + Σ w(u, v) × x[u] over neighbours u
y = y / ‖y‖ // Euclidean length 1
change = max |y[v] - x[v]|
x = y
until change < tol
return xThe x[v] term means that the iteration multiplies by A + I instead of A. Both matrices have the same eigenvectors, but A + I has no eigenvalue -λ to compete with λ, so the scores cannot swing back and forth on a bipartite graph. Each round costs one pass over the edges.
Load the example: a dense core, and a hub whose neighbours are unimportant.
Example graph: A, B, C and D are all linked to each other. E is linked to A, B and C. D also leads to F, and F has four more neighbours, G, H, I and J, that know nobody else. F has the most neighbours, five, and E only three.
Eigenvector centrality rewards being connected to the core. F is a local star whose followers count for little, while all three of E's neighbours are among the most central vertices. Degree ranks F first, eigenvector centrality ranks it sixth.
Time: O(k(V + E)) · Space: O(V)
Each round looks at every edge twice, once from each end, and at every vertex once: O(V + E). The number of rounds k depends on the gap between the two largest eigenvalues, since the error shrinks by the factor |λ2 / λ1| per round. A graph with a clear core converges in a few dozen rounds, one with two similar cores takes much longer. Only two vectors of length V are stored. For very large graphs the same iteration runs on sparse matrices, and Lanczos or Arnoldi methods (scipy.sparse.linalg.eigs) converge faster.
Eigenvector centrality belongs to a family of spectral rankings that differ in how they treat direction and dead ends.
| Alternative | Prefer it when | Cost |
|---|---|---|
| Degree centrality | When only direct contacts matter. It is also what eigenvector centrality looks like after a single round. | O(V + E) |
| Eigenvector centrality | Undirected, connected networks where influence flows through neighbours: social ties, collaboration, co-expression. | O(k(V + E)) |
| Katz centrality | Adds a small base score to every vertex, so vertices outside the core and directed graphs without cycles still get nonzero scores. | O(k(V + E)) |
| PageRank | Directed graphs such as the web: it splits each vertex's score over its out-links and adds a random jump. | O(k(V + E)) |
Read the full article: Graph Centrality Measures: Degree, Betweenness, PageRank
Read the full article: Spectral Graph Theory in Machine Learning
Related algorithms: PageRank, HITS (Hubs and Authorities), Closeness Centrality, Betweenness Centrality