TExcelTAD
Home › Spectral Graph Theory & Modern Graph Algorithms › Spectral Graph Theory: What This Course Covers

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 Rk\mathbb{R}^k 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 Lx=bLx = b 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

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 L=D−AL = D - A, takes the eigenvector of the second smallest eigenvalue (the Fiedler vector) and splits the vertices by its sign.

python · try it yourself
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 LL). 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 Lx=es−etLx = \mathbf{e}_s - \mathbf{e}_t gives the potentials when one unit of current flows from ss to tt, and the potential difference xs−xtx_s - x_t is the effective resistance between them. It is small when ss and tt are joined by many short, independent routes, and large when everything must squeeze through a bottleneck, information that shortest-path distance does not see.

python · try it yourself
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 xTLx=∑(u,v)∈E(xu−xv)2x^{\mathsf{T}} L x = \sum_{(u,v) \in E} (x_u - x_v)^2, λ2>0\lambda_2 > 0 iff connected
Expanders conductance, Cheeger's inequality, sweep cuts, the expander mixing lemma, constructions, random walks, walks on expanders ν22≤ϕ(G)≤2ν2\frac{\nu_2}{2} \le \phi(G) \le \sqrt{2\nu_2} (ν2\nu_2 of the normalized Laplacian), Alon-Boppana 2d−12\sqrt{d-1}
Spectral clustering kk-way clustering with kk 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 nn vertices and mm edges, and weights we>0w_e > 0 (unweighted means all weights 1). Eigenvalues of symmetric matrices are listed in increasing order, λ1≤λ2≤⋯≤λn\lambda_1 \le \lambda_2 \le \cdots \le \lambda_n, for Laplacians, and in decreasing order μ1≥μ2≥⋯≥μn\mu_1 \ge \mu_2 \ge \cdots \ge \mu_n 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 L=D−AL = D - A of any graph, which vector is always an eigenvector with eigenvalue 0?

  1. The degree vector
  2. The all-ones vector 1\mathbf{1}
  3. The first standard basis vector
  4. None in general

In the taste program, how were the two communities found?

  1. By BFS from vertex 0
  2. By the signs of the eigenvector of the second smallest Laplacian eigenvalue
  3. By the largest eigenvalue of LL
  4. By trying all 2202^{20} cuts

Why do the lessons fix the sign of every printed eigenvector?

  1. Negative entries are not allowed
  2. If vv is an eigenvector, so is −v-v, and libraries may return either one
  3. To make the eigenvalue positive
  4. Because NumPy returns complex vectors