AnyLearn
All lessons
Mathadvanced

Spectral Graph Theory: What the Laplacian's Eigenvalues Reveal

Turn a graph into its Laplacian matrix and its eigenvalues start answering combinatorial questions: how many components, how many spanning trees, how hard the graph is to cut, and where to cut it. Covers the Fiedler vector, Cheeger's inequality, spectral clustering, random-walk mixing, and expanders.

Updated · AI-authored, review-gated · how lessons are made

Progress1 / 10

Writing a graph as a matrix

Spectral graph theory studies a graph through the eigenvalues and eigenvectors of a matrix built from it. Three matrices do most of the work. For an undirected graph on nn vertices:

  • the adjacency matrix AA, with Aij=1A_{ij} = 1 when ii and jj are adjacent (or the edge weight);
  • the degree matrix DD, diagonal, with Dii=deg⁡(i)D_{ii} = \deg(i);
  • the Laplacian L=D−AL = D - A.

For the path 1−2−31 - 2 - 3:

L=(1−10−12−10−11)L = \begin{pmatrix} 1 & -1 & 0 \\ -1 & 2 & -1 \\ 0 & -1 & 1 \end{pmatrix}

Every row sums to zero, because each diagonal degree is cancelled by that many off-diagonal −1-1s. The name comes from calculus: applied to a function on the vertices, (Lx)i=∑j∼i(xi−xj)(Lx)_i = \sum_{j \sim i} (x_i - x_j) measures how far xix_i sits from its neighbours, the discrete analogue of the Laplace operator.

Definition: The spectrum of a graph is the multiset of eigenvalues of one of these matrices. Since LL is real and symmetric, its eigenvalues are real and it has an orthonormal basis of eigenvectors, so we can order them λ1≤λ2≤⋯≤λn\lambda_1 \le \lambda_2 \le \dots \le \lambda_n.

Sign in free to save your progress and earn certificates.

Full lesson text

All 10 steps on one page, for reading, reference, and search.

Show

1. Writing a graph as a matrix

Spectral graph theory studies a graph through the eigenvalues and eigenvectors of a matrix built from it. Three matrices do most of the work. For an undirected graph on nn vertices:

  • the adjacency matrix AA, with Aij=1A_{ij} = 1 when ii and jj are adjacent (or the edge weight);
  • the degree matrix DD, diagonal, with Dii=deg⁡(i)D_{ii} = \deg(i);
  • the Laplacian L=D−AL = D - A.

For the path 1−2−31 - 2 - 3:

L=(1−10−12−10−11)L = \begin{pmatrix} 1 & -1 & 0 \\ -1 & 2 & -1 \\ 0 & -1 & 1 \end{pmatrix}

Every row sums to zero, because each diagonal degree is cancelled by that many off-diagonal −1-1s. The name comes from calculus: applied to a function on the vertices, (Lx)i=∑j∼i(xi−xj)(Lx)_i = \sum_{j \sim i} (x_i - x_j) measures how far xix_i sits from its neighbours, the discrete analogue of the Laplace operator.

Definition: The spectrum of a graph is the multiset of eigenvalues of one of these matrices. Since LL is real and symmetric, its eigenvalues are real and it has an orthonormal basis of eigenvectors, so we can order them λ1≤λ2≤⋯≤λn\lambda_1 \le \lambda_2 \le \dots \le \lambda_n.

2. The quadratic form that explains everything

The Laplacian's power comes from one identity. For any real vector xx assigning a number to each vertex,

x⊤Lx  =  ∑{i,j}∈E(xi−xj)2x^{\top} L x \;=\; \sum_{\{i,j\} \in E} (x_i - x_j)^2

The right side is a sum of squares, so it is never negative: LL is positive semidefinite and every λi≥0\lambda_i \ge 0. The all-ones vector 1\mathbf{1} makes every term zero, so λ1=0\lambda_1 = 0 always.

Read the sum as the energy of a labelling: it is small when adjacent vertices get similar values and large when edges join very different values. By the Courant-Fischer theorem, the second eigenvalue is the least energy achievable by a labelling of unit length that is not just a constant shift:

λ2  =  min⁡x⊥1, ∥x∥=1 ∑{i,j}∈E(xi−xj)2\lambda_2 \;=\; \min_{x \perp \mathbf{1},\ \lVert x\rVert = 1} \ \sum_{\{i,j\} \in E} (x_i - x_j)^2

Key idea: A low-energy labelling orthogonal to constants must give positive values to some vertices and negative values to others while keeping edges between the two groups rare. So a small λ2\lambda_2 means the graph has a cheap way to split, and the minimising vector shows where.

3. What the zero eigenvalues count

If x⊤Lx=0x^{\top} L x = 0, every edge term vanishes, so xx is constant on each connected component. Conversely, the indicator vector of any component has zero energy. So the null space of LL is spanned by the component indicators:

Key idea: The multiplicity of the eigenvalue 0 equals the number of connected components. In particular, λ2>0\lambda_2 > 0 if and only if the graph is connected.

This is the bridge back to the first lesson of this path: connectivity, a combinatorial property, is visible in linear algebra. The spectrum knows more. Kirchhoff's matrix-tree theorem (1847) states that the number of spanning trees of a connected graph is

τ(G)=1n λ2λ3⋯λn\tau(G) = \frac{1}{n}\,\lambda_2 \lambda_3 \cdots \lambda_n

Predict first

The Laplacian of the complete graph K4K_4 has eigenvalues 0,4,4,40, 4, 4, 4. How many spanning trees does K4K_4 have?

4. Algebraic connectivity: how well-knit a graph is

Fiedler (1973, Czechoslovak Mathematical Journal) named λ2\lambda_2 the algebraic connectivity and proved that for any graph other than a complete graph it is bounded by the vertex connectivity from the first lesson, λ2≤κ(G)\lambda_2 \le \kappa(G). It is a smooth, computable proxy for robustness: it grows as a graph gets harder to cut.

Algebraic connectivity of four 10-vertex graphs
second Laplacian eigenvalue02468100.10.38110PathCycleStarComplete
Source: Computed from the closed forms 2(1 - cos(pi/n)), 2(1 - cos(2pi/n)), 1 and n, checked with NetworkX algebraic_connectivity

The path is the easiest to cut and scores lowest; the cycle needs two cuts and scores about four times higher; the complete graph is maximally knit. The star is instructive: one cut vertex disconnects it, yet it scores 1, about ten times the path. Algebraic connectivity measures how expensive a split is relative to its sizes, not only whether a split exists.

In practice: In consensus and formation-control systems, where agents repeatedly average with neighbours, convergence speed scales with λ2\lambda_2 of the communication graph, as Olfati-Saber and Murray (2004, IEEE Transactions on Automatic Control) showed. Adding the single edge that most raises λ2\lambda_2 is a standard network design question.

5. The Fiedler vector finds the split

The eigenvector for λ2\lambda_2, the Fiedler vector, is the minimum-energy labelling, so its signs suggest a partition. Two triangles joined by one edge make the point.

import numpy as np

edges = [(0, 1), (1, 2), (0, 2),      # triangle one
         (2, 3),                      # the bridge
         (3, 4), (4, 5), (3, 5)]      # triangle two
n = 6
A = np.zeros((n, n))
for i, j in edges:
    A[i, j] = A[j, i] = 1
L = np.diag(A.sum(axis=1)) - A

vals, vecs = np.linalg.eigh(L)        # eigenvalues in ascending order
print(np.round(vals, 3))   # [0.    0.438 3.    3.    3.    4.562]
f = vecs[:, 1]
print(np.round(f, 3))      # [-0.465 -0.465 -0.261  0.261  0.465  0.465]
print(np.where(f < 0)[0], np.where(f >= 0)[0])   # [0 1 2] [3 4 5]

The vector is antisymmetric across the bridge, the two endpoints of the bridge (vertices 2 and 3) sit closest to zero, and the sign split recovers the two triangles exactly. λ2≈0.44\lambda_2 \approx 0.44 is small next to the other nonzero eigenvalues, which is the spectral signature of a bottleneck.

Gotcha: An eigenvector's sign is arbitrary, so another library may return −f-f. When λ2\lambda_2 is repeated, any vector in its eigenspace is valid and the split is not unique.

6. Cheeger's inequality: why the split is good

Finding the cut that best balances size against edges crossing it is NP-hard. Measure a vertex set SS by its conductance, the edges leaving it divided by the smaller side's total degree (its volume):

ϕ(S)=∣E(S,Sˉ)∣min⁡(vol(S), vol(Sˉ)),ϕ(G)=min⁡Sϕ(S)\phi(S) = \frac{\lvert E(S, \bar S)\rvert}{\min\big(\mathrm{vol}(S),\ \mathrm{vol}(\bar S)\big)}, \qquad \phi(G) = \min_S \phi(S)

Using ν2\nu_2, the second eigenvalue of the normalized Laplacian (next steps), the discrete Cheeger inequality brackets the hard quantity with the easy one:

ν22  ≤  ϕ(G)  ≤  2 ν2\frac{\nu_2}{2} \;\le\; \phi(G) \;\le\; \sqrt{2\,\nu_2}

The graph versions are due to Dodziuk (1984) and Alon and Milman (1985), after Cheeger's 1970 result for manifolds; these constants are as stated in Daniel Spielman's Yale lecture notes on spectral graph theory. The upper bound is constructive: sort vertices by their eigenvector values, try the n−1n - 1 "sweep" cuts that split the sorted order, and keep the best. One of them always achieves conductance at most 2ν2\sqrt{2\nu_2}.

Key idea: A small eigenvalue guarantees a good cut exists and the sweep finds one; a large eigenvalue proves no good cut exists at all. The spectrum is a certificate in both directions, like the flows and matchings of the previous lessons, though here only up to a square root.

7. Spectral clustering, end to end

Spectral clustering applies the same idea to data that does not start as a graph. Shi and Malik (2000, IEEE Transactions on Pattern Analysis and Machine Intelligence) introduced normalized cuts for image segmentation, and Ng, Jordan and Weiss (2002) gave the widely used kk-way recipe below. Its advantage over running kk-means directly is that the eigenvector embedding turns clusters defined by connectivity, such as two interleaved rings, into compact blobs that kk-means can separate.

flowchart LR
  A["Data points"] --> B["Similarity graph: kNN or Gaussian weights"]
  B --> C["Normalized Laplacian"]
  C --> D["k smallest eigenvectors"]
  D --> E["Each point becomes a row in k dimensions"]
  E --> F["k-means on the rows"]
  F --> G["Cluster labels"]

8. Which Laplacian to use

When degrees vary a lot, the plain Laplacian favours cutting off a few low-degree vertices, because it counts vertices rather than edges. Normalizing by degree fixes that. Three versions are standard:

MatrixFormulaCut it relaxesNotes
UnnormalizedL=D−AL = D - Aratio cut, balance by vertex countsimplest; fine for near-regular graphs
Symmetric normalizedLsym=I−D−1/2AD−1/2L_{\mathrm{sym}} = I - D^{-1/2} A D^{-1/2}normalized cut, balance by volumesymmetric; eigenvalues lie in the interval from 0 to 2
Random-walkLrw=I−D−1AL_{\mathrm{rw}} = I - D^{-1} Anormalized cutsame eigenvalues as LsymL_{\mathrm{sym}}; eigenvectors are D−1/2D^{-1/2} times its

The last two share a spectrum, and ν2\nu_2 in Cheeger's inequality is their second eigenvalue. Von Luxburg's tutorial (2007, Statistics and Computing) recommends normalized spectral clustering, and specifically LrwL_{\mathrm{rw}}, when degrees are uneven.

Gotcha: The similarity graph matters more than the Laplacian. A Gaussian kernel with too small a width disconnects the data into singletons, each adding another zero eigenvalue; too large a width connects everything to everything. Check the eigenvalue gap: a clear jump after the kk-th smallest eigenvalue is the evidence that kk clusters exist.

9. Random walks, mixing, and expanders

A random walk moves from a vertex to a uniformly random neighbour, with transition matrix P=D−1AP = D^{-1} A. Since Lrw=I−PL_{\mathrm{rw}} = I - P, each eigenvalue ν\nu of LrwL_{\mathrm{rw}} is 1−μ1 - \mu for an eigenvalue μ\mu of PP. The walk's distribution converges to its stationary distribution, proportional to degree, at a rate governed by the spectral gap: for the lazy walk that stays put half the time, the distance to stationarity shrinks roughly like (1−ν2/2)t(1 - \nu_2/2)^t after tt steps.

So a bottleneck, small ν2\nu_2, is exactly what traps a walk and slows mixing. This is the same fact as Cheeger's inequality seen from the walker's side, and it is why PageRank adds random teleportation: it guarantees a gap.

Expanders are the opposite extreme: sparse graphs, often with every degree equal to a fixed dd, whose spectral gap stays bounded away from zero as nn grows. For dd-regular graphs the second-largest adjacency eigenvalue cannot be much below 2d−12\sqrt{d-1} (the Alon-Boppana bound), and graphs that meet it are called Ramanujan; Lubotzky, Phillips and Sarnak (1988) gave explicit constructions.

In practice: Expanders are sparse yet impossible to cut cheaply, which is why they appear in error-correcting codes, derandomisation, and robust network topologies. A random walk on one mixes in O(log⁡n)O(\log n) steps.

10. What the spectrum cannot tell you

The spectrum is a summary, and summaries lose information.

Gotcha: Different graphs can share a spectrum. The smallest example, found by Collatz and Sinogowitz (1957), is the star with four leaves and the disjoint union of a 4-cycle with an isolated vertex: both have adjacency eigenvalues −2,0,0,0,2-2, 0, 0, 0, 2, yet one is connected and the other is not. Their Laplacian spectra differ, but other pairs share Laplacian spectra too. You cannot recover a graph, or test isomorphism, from eigenvalues alone.

Practical limits matter as much as theoretical ones:

  • Cost. A dense eigendecomposition such as np.linalg.eigh takes O(n3)O(n^3) time and O(n2)O(n^2) memory, which is out of reach for a million-vertex graph. Use a sparse matrix and an iterative solver such as scipy.sparse.linalg.eigsh or lobpcg, which compute only the few eigenvectors you need.
  • Directed graphs. AA is no longer symmetric, eigenvalues can be complex, and the clean energy picture is gone. Symmetrise deliberately, or use methods built for digraphs.
  • Approximation. The Fiedler sweep is within the Cheeger square-root factor, not optimal. When an exact ss-tt cut is what you need, max flow from the second lesson gives it exactly.

Check your understanding

The lesson ends with a 5-question quiz. Take it in the player above to see your score.

  1. The Laplacian of a graph has eigenvalue 0 with multiplicity 3. What do you know?
    • The graph has 3 cut vertices
    • The graph is 3-connected
    • The graph has exactly 3 connected components
    • The graph has 3 spanning trees
  2. Why is the smallest Laplacian eigenvalue always 0?
    • Because the all-ones vector has zero energy: every (x_i - x_j)^2 term vanishes
    • Because the adjacency matrix always has a zero on its diagonal
    • Because every graph contains at least one isolated vertex
    • Because the trace of L is zero
  3. What does the upper bound in Cheeger's inequality, phi(G) <= sqrt(2 nu_2), guarantee in practice?
    • That spectral clustering always finds the optimal cut
    • That the graph is an expander
    • That the eigenvalue equals the minimum cut size
    • That some sweep cut of the sorted eigenvector has conductance at most sqrt(2 nu_2)
  4. A dataset's similarity graph has wildly uneven degrees. Which choice does von Luxburg's tutorial recommend?
    • The unnormalized Laplacian D - A
    • The random-walk normalized Laplacian I - D^-1 A
    • The adjacency matrix's largest eigenvectors
    • Running k-means directly on the raw data
  5. Two graphs have identical adjacency spectra. What follows?
    • They are isomorphic
    • They have the same number of connected components
    • They have the same number of vertices and edges, but may differ in structure, even in connectivity
    • They have identical Fiedler vectors

Related lessons

Math
intermediate

The Phase Plane: Linear Systems, Eigenvalues, and Limit Cycles

Two variables make oscillation possible. Classify every fixed point of a linear system from its eigenvalues or from trace and determinant, linearize nonlinear systems with the Jacobian, analyse the Lotka-Volterra predator-prey model and its conserved quantity, and see why limit cycles are the robust oscillators and why the plane cannot be chaotic.

10 steps·~15 min
Math
intermediate

Matching: Augmenting Paths, Hall, König, and the Assignment Problem

Pair workers with tasks, the most pairs or the cheapest total. Learn why augmenting paths prove a matching is maximum, how Hall's and König's theorems give certificates, how the Hungarian method prices an assignment, and why odd cycles and preferences each change the problem.

10 steps·~15 min
Math
intermediate

Network Flows: Augmenting Paths and the Max-Flow Min-Cut Theorem

Why pushing flow greedily gets stuck, how the residual graph makes every decision reversible, and why the maximum flow always equals the minimum cut. Build Edmonds-Karp in Python, compare the classic algorithms, and see cuts solve image segmentation and project selection.

10 steps·~15 min
Math
intermediate

Graph Connectivity: Bridges, Cut Vertices, and Menger's Theorem

Connected is only the first question; how much damage a graph can absorb is the useful one. Learn vertex and edge connectivity, find every bridge and cut vertex in one depth-first search, and see Menger's theorem turn minimum cuts into a count of disjoint paths.

10 steps·~15 min