learngraphtheory.org

Guest

Sign in to keep your graphs and progress.

Cover of the book Graph Theory Through Problems

Practice book

Graph Theory Through Problems

300 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.

Available inKindlePaperback

13 chapters

Also by the authorGraph Algorithms for Coding Interviews100 solved interview problems with visual explanations and Python solutions.View on Amazon
Algorithm Selection

Select an algorithm and generate steps to begin visualization

Eigenvector Centrality Visualizer

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

Time: O(k(V + E))
Space: O(V)
Use Case: Social influence, link analysis, biological networks
Showing the example graph for this algorithm.
Algorithm Execution

Select an algorithm and generate steps to begin visualization

About Eigenvector Centrality

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.

How it works

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.

Applications

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.

Pseudocode

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 x

The 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.

Worked example, step by step

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.

  1. Round 1: degree wins. Every vertex starts at 0.316. After one round each score is 0.316 times (1 + degree), so F, with the most neighbours, leads with 1.897, and the leaves G to J have 0.632.
  2. Round 2: the core takes over. Now each vertex adds up the new scores of its neighbours. F's neighbours are mostly weak leaves, while the core vertices pass high scores to each other, so D moves into the lead.
  3. Converging. The changes shrink by a roughly constant factor every round. After 19 rounds no score moves by more than 0.0001, and A, B and C share the top score.
  4. The result. A, B and C 0.465, D 0.419, E 0.376, F 0.16 and the leaves 0.043. E, with three neighbours, ends far above F with five.

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.

Complexity, and where it comes from

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.

When to use Eigenvector Centrality, and when not to

Eigenvector centrality belongs to a family of spectral rankings that differ in how they treat direction and dead ends.

AlternativePrefer it whenCost
Degree centralityWhen only direct contacts matter. It is also what eigenvector centrality looks like after a single round.O(V + E)
Eigenvector centralityUndirected, connected networks where influence flows through neighbours: social ties, collaboration, co-expression.O(k(V + E))
Katz centralityAdds 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))
PageRankDirected graphs such as the web: it splits each vertex's score over its out-links and adds a random jump.O(k(V + E))

Common pitfalls

  • Directed graphs without cycles. On a directed graph the scores flow along the edges and drain away at vertices with no way back. On a graph without cycles they all reach zero. Use PageRank or Katz centrality, which add a base score, or HITS.
  • Disconnected graphs. Only the component with the largest eigenvalue keeps nonzero scores, and the others fade to zero. If every component matters, compute the centrality per component or use Katz centrality or PageRank.
  • Bipartite graphs. Plain multiplication by A makes the scores swing between the two sides forever, because -λ is an eigenvalue too. The A + I shift used here, or any damping, fixes it without changing the answer.
  • Scale of the numbers. The scores are only defined up to a factor. NetworkX scales them to length 1, other tools to a maximum of 1 or a sum of 1. Compare rankings and ratios, not raw values from different tools.

Frequently asked questions

What does eigenvector centrality measure?
It measures how well a vertex is connected to other well-connected vertices. A score is proportional to the sum of the neighbours' scores, so one link to a central vertex can be worth more than many links to peripheral ones.
How is eigenvector centrality different from PageRank?
PageRank is eigenvector centrality adapted to directed graphs: a vertex shares its score equally among its out-links, and a damping factor adds a random jump to any vertex. That keeps every score positive even on graphs with dead ends, where plain eigenvector centrality collapses.
Why does the power iteration converge?
Write the starting vector as a sum of eigenvectors. Each multiplication by the matrix scales every part by its eigenvalue, so the part with the largest eigenvalue grows fastest and, after rescaling, is all that is left. By the Perron-Frobenius theorem that part is positive on a connected graph.
How do I compute eigenvector centrality in Python?
In NetworkX, nx.eigenvector_centrality(G) runs the same power iteration with A + I and scaling to length 1 as this visualizer, and nx.eigenvector_centrality_numpy(G) calls a dense eigensolver. Pass weight='weight' to use edge weights.

Related algorithms: PageRank, HITS (Hubs and Authorities), Closeness Centrality, Betweenness Centrality

An example graph: you can change it, or start blank.

Zoom Controls

30%
Nodes: 10
Edges: 14