Spectral Graph Theory: What This Course Covers
A graph is a combinatorial object: vertices, edges, paths, cuts. Write it down as a matrix, though, and linear algebra starts to answer combinatorial questions. The eigenvalues of the Laplacian matrix tell you whether the graph is connected, how badly it is connected (whether a small set of edges separates it into two large pieces), how fast a random walk on it forgets its starting point, and how much current flows between two vertices if every edge is a one-ohm resistor. The eigenvectors go further: they find the sparse cuts, embed the graph in the plane or in so that clusters fall apart, and give the potentials of an electrical flow.
This is the last course of Part II of the track. It has two halves. The first is classical spectral graph theory: graph matrices and their spectra, the Courant-Fischer theorem, the Fiedler vector, Cheeger's inequality, expanders and spectral clustering. The second is the Laplacian paradigm of modern graph algorithms: solving the linear system in nearly linear time, and using that solver (electrical flows, effective resistances, sparsifiers) as a primitive for cuts and flows, up to the 2022 almost-linear-time maximum flow algorithm.
What you should know first
- Linear algebra. Eigenvalues and eigenvectors (Eigenvectors), the spectral theorem for symmetric matrices (Symmetric Diagonalization), positive semidefinite matrices and quadratic forms (Positive Definite Matrices, Quadratic Forms). This course uses these facts without re-proving them.
- Graph algorithms. BFS, connectivity and maximum flow from Graph Algorithms, in particular The Max-Flow Min-Cut Theorem.
- Random walks. Mixing time and conductance were introduced for Markov chains in Stationary Distributions and Mixing Time and Conductance and the Cheeger Bound. Here they are redone for graphs with full proofs of the parts that matter for algorithms.
- Sparsifiers. Cut Sparsifiers and Spectral Sparsifiers gave the streaming view; this course explains the linear algebra behind them.
A taste: one eigenvector finds two communities
The program builds a random graph with two planted communities of 10 vertices each: inside a community an edge appears with probability 0.6, across with probability 0.05. It never looks at the planted labels when it partitions. It computes the Laplacian , takes the eigenvector of the second smallest eigenvalue (the Fiedler vector) and splits the vertices by its sign.
import random
import numpy as np
rng = random.Random(7)
n, half = 20, 10
edges = [(u, v) for u in range(n) for v in range(u + 1, n)
if rng.random() < (0.6 if (u < half) == (v < half) else 0.05)]
A = np.zeros((n, n))
for u, v in edges:
A[u, v] = A[v, u] = 1
L = np.diag(A.sum(axis=1)) - A
vals, vecs = np.linalg.eigh(L) # ascending eigenvalues, orthonormal eigenvectors
f = vecs[:, 1]
f = f if f[np.flatnonzero(np.abs(f) > 1e-9)[0]] > 0 else -f # fix the sign: first entry positive
side = f > 0
print("edges:", len(edges))
print("smallest eigenvalues:", np.round(vals[:4], 4) + 0.0)
print("Fiedler vector signs:", "".join("+" if s else "-" for s in side))
print("planted communities: ", "".join("+" if v < half else "-" for v in range(n)))
cut = sum(side[u] != side[v] for u, v in edges)
print("edges crossing the spectral split:", cut)edges: 63
smallest eigenvalues: [0. 0.6143 3.2156 3.4877]
Fiedler vector signs: ++++++++++----------
planted communities: ++++++++++----------
edges crossing the spectral split: 4
The smallest eigenvalue is 0 (it always is: the all-ones vector is in the kernel of ). The second, about 0.61, is far below the third (about 3.22), and the signs of its eigenvector recover the planted communities exactly, cutting only 4 of the 63 edges. Why this works, when it provably works and when it fails is the subject of the first half of the course.
A second taste: one linear system measures connectivity
The second half of the course treats a graph as an electrical network. Solving the single linear system gives the potentials when one unit of current flows from to , and the potential difference is the effective resistance between them. It is small when and are joined by many short, independent routes, and large when everything must squeeze through a bottleneck, information that shortest-path distance does not see.
import numpy as np
def reff(n, edges, s, t):
L = np.zeros((n, n))
for u, v in edges:
L[u, u] += 1; L[v, v] += 1; L[u, v] -= 1; L[v, u] -= 1
b = np.zeros(n); b[s], b[t] = 1, -1
x = np.linalg.lstsq(L, b, rcond=None)[0] # any solution: potentials are defined up to a constant
return float(x[s] - x[t])
path = [(i, i + 1) for i in range(4)] # s = 0 and t = 4, distance 4
ladder = path + [(5 + i, 6 + i) for i in range(4)] + [(i, i + 5) for i in range(5)]
grid_like = ladder + [(10 + i, 11 + i) for i in range(4)] + [(5 + i, 10 + i) for i in range(5)]
for name, n, edges in [("path", 5, path), ("ladder (2 rows)", 10, ladder), ("3 x 5 grid", 15, grid_like)]:
print(f"{name:16} distance(0, 4) = 4, effective resistance {reff(n, edges, 0, 4):.4f}")path distance(0, 4) = 4, effective resistance 4.0000
ladder (2 rows) distance(0, 4) = 4, effective resistance 2.3636
3 x 5 grid distance(0, 4) = 4, effective resistance 2.0211
The distance between the two vertices is 4 in all three graphs, but every extra row of parallel routes lowers the resistance. The same quantity gives commute times of random walks, the sampling probabilities for graph sparsification, and the steps of the fastest maximum-flow algorithms.
Course map
| Section | Lessons | Key results |
|---|---|---|
| Graph matrices | adjacency, Laplacian, normalized Laplacian; spectra of standard families; Courant-Fischer; components; the Fiedler vector | , iff connected |
| Expanders | conductance, Cheeger's inequality, sweep cuts, the expander mixing lemma, constructions, random walks, walks on expanders | ( of the normalized Laplacian), Alon-Boppana |
| Spectral clustering | -way clustering with eigenvectors, the higher-order Cheeger inequality, failure cases | Shi-Malik, Ng-Jordan-Weiss, Lee-Oveis Gharan-Trevisan |
| Laplacian solvers and electrical flows | resistor networks, effective resistance, Schur complements, conjugate gradient, nearly-linear solvers, sparsification, electrical flows and maximum flow | Foster's theorem, Spielman-Teng, Spielman-Srivastava, Chen et al. 2022 |
| Practice | exercises, a spectral clustering tool |
Every lesson has runnable Python with NumPy and SciPy, and the lessons whose core is an algorithm (power iteration, sweep cuts, Gauss-Seidel, conjugate gradient, effective resistances) also have a C++ version using only the standard library.
Conventions
Unless a lesson says otherwise, graphs are undirected, without self-loops, with vertices and edges, and weights (unweighted means all weights 1). Eigenvalues of symmetric matrices are listed in increasing order, , for Laplacians, and in decreasing order for adjacency matrices. Several normalizations of the Laplacian and of conductance appear in the literature, and constants in theorems depend on them; every theorem in the course says which one it uses.
Numerical eigenvalues are printed rounded, and eigenvectors are normalized to have a positive first nonzero entry, because an eigenvector is only defined up to sign and different libraries return different signs.
Further reading
The topic order follows standard references; all text, programs and exercises here are original.
- Daniel A. Spielman, Spectral and Algebraic Graph Theory (book draft, Yale, 2019): the closest match to this course.
- Fan R. K. Chung, Spectral Graph Theory (AMS, 1997): the normalized Laplacian point of view.
- Shlomo Hoory, Nathan Linial and Avi Wigderson, Expander Graphs and Their Applications (Bulletin of the AMS, 2006).
- Ulrike von Luxburg, A Tutorial on Spectral Clustering (Statistics and Computing, 2007).
- Nisheeth K. Vishnoi, Lx = b: Laplacian Solvers and Their Algorithmic Applications (2013), and Shang-Hua Teng, The Laplacian Paradigm (2010).
Test yourself
For the Laplacian of any graph, which vector is always an eigenvector with eigenvalue 0?
- The degree vector
- The all-ones vector
- The first standard basis vector
- None in general
In the taste program, how were the two communities found?
- By BFS from vertex 0
- By the signs of the eigenvector of the second smallest Laplacian eigenvalue
- By the largest eigenvalue of
- By trying all cuts
Why do the lessons fix the sign of every printed eigenvector?
- Negative entries are not allowed
- If is an eigenvector, so is , and libraries may return either one
- To make the eigenvalue positive
- Because NumPy returns complex vectors