CComputer Science, Built

Act XI · The Research Frontier

Part 56 of 61

Spectral Graphs and Expanders

Researchstarts at this level53 min of film13 chaptersprerequisites: Part 18, Part 20, Part 27, Part 52

What do the eigenvalues of a graph's matrix know that its drawing hides?

The part opens on two 16-vertex rings with three neighbours at every vertex, alike in a drawing, whose second eigenvalues are 0.097 and 0.279, and reads the same number off Part 18's city grid, Part 36's internet and the word graph of a novel. The Laplacian's quadratic form is the energy of springs along the edges, and Courant-Fischer makes its second eigenvalue a relaxation of the minimum bisection. Cheeger's inequality is proved in both directions, and the sweep cut over the Fiedler vector is checked against brute force on random 12-vertex graphs. The same gap bounds how fast a lazy random walk forgets its start. Expanders are sparse graphs with a large gap: the mixing lemma, the Alon-Boppana limit, random regular graphs measured against it, and an explicit construction by the zig-zag product, which gave Reingold's SL = L. The part then turns the graph into a circuit: effective resistance, commute times, sparsifiers and Laplacian solvers, and electrical flows reweighted until they approximate a maximum flow. It ends at the almost-linear max-flow algorithm of 2022, at high-dimensional expanders, and at the small-set expansion hypothesis.

What you need. Linear algebra to the spectral theorem for symmetric matrices, and Markov chains at the level of a stationary distribution.

Mathematics, ideas and history
Laplacians, Cheeger's inequality, mixing times, expanders and the zig-zag product, SL = L, Laplacian solvers, almost-linear max-flow
What we build or compute
spectral partitions of the novels' word graph; a zig-zag expander

What you will be able to do

Degree

  • Write the Laplacian of a small graph and evaluate its quadratic form as a sum over edges.
  • Explain what a small second eigenvalue says about cutting a graph in two.

Graduate

  • Compute the conductance of a cut, and find a sweep cut from the Fiedler vector.
  • Bound a lazy walk's mixing time from the spectral gap, above and below.
  • Compute an effective resistance and predict a commute time from it.

Research

  • Prove both sides of Cheeger's inequality, the hard side by a random threshold cut.
  • Prove the expander mixing lemma, and state the Alon-Boppana bound and what the zig-zag product preserves.
  • State the small-set expansion hypothesis and its relation to the unique games conjecture.

Industry

  • Partition a graph by spectral clustering, and read a sweep curve to choose the cut.
  • Explain why a random regular graph is a good datacentre topology, and how a walk on an expander saves random bits.

Contents

Each chapter has a home level. Choose a track to see what to read and watch: Degree 8 min · Graduate 12 min · Research 53 min · Industry 12 min.

  1. 0What eigenvalues know about a graphDegree2 min
  2. 1The LaplacianDegree4 min
  3. 2Rayleigh quotients and the Fiedler vectorResearch4 min
  4. 3Cheeger's inequalityResearch5 min
  5. 4Random walks and mixingResearch5 min
  6. 5ExpandersResearch4 min
  7. 6Explicit expanders: the zig-zag productResearch5 min
  8. 7Expanders at workIndustry4 min
  9. 8Graphs as electrical networksResearch5 min
  10. 9Laplacian solvers and sparsifiersResearch5 min
  11. 10From electrical flows to max-flowResearch5 min
  12. 11Frontier: high-dimensional expandersResearch2 min
  13. Recap, problems, and where this comes backAll tracks2 min

Also on this page: Lecture · Key results · Try it · Lab · Problems · Notes and sources · 中文 · Build the film.

Lecture

The text of each chapter is the film's narration, as it is spoken, so you can read along or revise without the film. The pictures are in the film.

What eigenvalues know about a graphDegree2 min

Here are two graphs. Each has sixteen vertices arranged in a ring, and some extra edges. On the left the extra edges are short chords between near neighbours; on the right they are random. In a drawing they look much alike. But one number tells them apart: the second smallest eigenvalue of a matrix built from the graph. On the left it is small: the graph is easy to cut in two, and a random walk on it takes a long time to forget where it started. On the right it is almost three times larger: no cut is cheap, and walks mix fast. This part is about what the eigenvalues of a graph know.

The same number, computed for three graphs this series has already built. Part 18's city grid has 256 intersections, and its second eigenvalue is tiny: about 0.009. A grid is easy to cut through the middle, and the cut the eigenvector finds crosses only a few roads. Part 36's internet of providers and customers, and a graph of words that occur near each other in one of our novels, are far better connected. By the end of this part we will know why this one eigenvalue bounds how hard a graph is to cut, how fast it mixes, and how it carries electric current, and how those facts led, in 2022, to the fastest known algorithm for maximum flow.

1The LaplacianDegree4 min

The Laplacian, the matrix that sees the shape of a graph. Start with a small graph: five vertices and five edges. Write down two matrices. The degree matrix, D, has each vertex's number of neighbours on its diagonal. The adjacency matrix, A, has a one wherever two vertices are joined. Their difference, D minus A, is the Laplacian of the graph. Read one row, the third vertex's: its degree, three, on the diagonal, and minus one for each of its three neighbours. So every row sums to zero, and the Laplacian sends the all-ones vector to zero. The name comes from physics: the Laplacian at a vertex compares its value with its neighbours' values, a discrete second derivative, up to sign.

Why this matrix? Because of the number it gives when you put a vector on both sides of it: x transpose L x, for any labelling x of the vertices by numbers. Split L into its two parts. The degree part counts each vertex's square once for every edge it touches; the adjacency part gives twice the product across every edge. Gather both by edges: each edge brings x i squared, plus x j squared, minus twice their product. And that is a perfect square. The quadratic form of the Laplacian is the sum, over the edges, of the squared difference across each edge. Think of each edge as a spring and of x as the heights of the vertices: this is the energy stored in the springs. A labelling that changes slowly along the edges stores little energy, seven units here. The same five values, rearranged so that they jump across edges, store thirty-nine.

That energy is never negative, so every eigenvalue of the Laplacian is at least zero. We number them from the smallest: lambda one, which is always zero, with the all-ones vector, then lambda two, and up to lambda n. When is the energy exactly zero? Only when no edge has a difference across it: when x is constant on every connected piece of the graph. This graph has two pieces, and two independent ways to do that: light up the left piece, or the right one. So zero is an eigenvalue twice. In general, the number of zero eigenvalues is the number of components. Now add a single bridge. The graph is connected, one zero eigenvalue rises, and it does not rise far: lambda two is small, because one edge barely holds the halves together.

So lambda two is zero exactly when the graph falls apart, and its size says how firmly the graph holds together. Here are four graphs on eight vertices, from the sparsest connected one, a path, through a cycle and a cube, to the complete graph. Their second eigenvalues climb from about fifteen hundredths to eight. Miroslav Fiedler studied this number in 1973 and named it the algebraic connectivity. Adding an edge can never lower it, which the next chapter proves, and unless the graph is complete it is at most the vertex connectivity, the fewest vertices whose removal disconnects the graph. It is a robust, continuous measure of something the drawing only hints at.

Real graphs rarely fall apart completely, but they often nearly do. This graph has a hundred and twenty vertices in two planted communities of sixty, with edges dense inside each community and sparse between. Its twelve smallest eigenvalues: zero, as always; then one eigenvalue that stands apart, about three; and then the bulk, starting above four and a half. The pattern generalizes the exact case: a graph that almost falls into k pieces has k eigenvalues near zero, followed by a gap.

2Rayleigh quotients and the Fiedler vectorResearch4 min

Chapter one promised that adding an edge never lowers lambda two. The tool that proves it, and much more, is the Rayleigh quotient: the energy of a labelling divided by its size. Because L is symmetric, its eigenvectors can be chosen orthonormal, and any x is a combination of them. In that basis the cross terms vanish: the energy is a sum of eigenvalues times squared coefficients, and the size is the sum of the squared coefficients. So the Rayleigh quotient is a weighted average of the eigenvalues, each weighted by how much of x lies along its eigenvector. Move the weights and the average moves, but it never leaves the range of the eigenvalues. Its smallest value, zero, comes from putting all the weight on the first eigenvector, the constant one.

Now forbid the constant vector: allow only labellings orthogonal to the all-ones vector, whose values sum to zero. Then the first weight is zero, the average runs over lambda two and above, and it can never be smaller than lambda two. Put all the weight on the second eigenvector and the average reaches lambda two exactly. So lambda two is the smallest Rayleigh quotient among vectors orthogonal to the constant. The general statement is the Courant–Fischer theorem: the k-th eigenvalue is the best, over all k-dimensional subspaces, of the worst quotient inside. Ernst Fischer proved it in 1905, and Richard Courant extended it in 1920. And here is chapter one's promise. Adding an edge adds a square to the energy of every vector, so every quotient rises, and with them every eigenvalue.

Why should an eigenvector know where to cut? Write a cut as a vector: minus one on one side, plus one on the other. An edge inside a side contributes nothing to the energy; an edge across the cut contributes four. So the energy is four times the number of edges cut. Asking for the best cut into two equal halves, the minimum bisection, means minimizing the energy over vectors of plus and minus ones that sum to zero. That problem is NP-hard. So relax it: allow any real values with the same sum and the same length. The minimum can only drop, and by Courant–Fischer the relaxed minimum is n over four times lambda two: a lower bound on every bisection, and the vector that attains it is the second eigenvector.

Here is the second eigenvector of the bridged graph, drawn as colours: blue for negative entries, orange for positive, brighter for larger. It is negative on one cluster and positive on the other, and smallest in size at the two ends of the bridge, where it changes sign. On a grid it is a slow wave along the long side, so the cut it suggests goes straight across the middle, the cheap cut of Part 18's city. Line the vertices up by their values, and you get the Fiedler order. Splitting it at zero separates the clusters. Fiedler showed in 1975 that this is no accident: in a connected graph, the vertices where the vector is not negative always form a connected piece.

Now a graph too large to read by eye: chapter one's hundred and twenty vertices in two planted communities. Compute the second eigenvector from the edges alone, without the labels, and plot each vertex's entry, with the first sixty vertices belonging to community A. Every vertex of A has a negative entry and every vertex of B a positive one. The signs recover the planted communities exactly. Nobody told the matrix which vertex belonged where.

3Cheeger's inequalityResearch5 min

Chapter two cut graphs with an eigenvector; now we prove how well it cuts. The volume of a set of vertices is the sum of their degrees, and the conductance of a cut is the number of edges it crosses, divided by the volume of the smaller side. Cutting off three vertices crosses two edges, but the side is small: conductance a quarter. Cutting between the clusters crosses the same two edges with a far bigger side: one ninth. The conductance of the graph is that of its best cut, and finding it is NP-hard. Cheeger's inequality says lambda two of the normalized Laplacian pins it down from both sides: at least half of lambda two, at most the square root of twice lambda two. Jeff Cheeger proved it for curved manifolds in 1970; the graph versions followed in the nineteen-eighties.

The easy direction says that a cheap cut forces a small eigenvalue. Write lambda two of the normalized Laplacian as a minimum over vectors y, by substituting x equals the square root of D times y. Now we need just one good test vector. Take any set S, and put one over its volume on S and minus one over the other side's volume off it. Its degree-weighted sum is zero, so it is allowed. Only the cut edges have a difference across them, all the same size. One factor cancels, and each of the two terms is at most one over the smaller volume. So lambda two is at most twice the conductance of S, for every S, and in particular for the best.

The hard direction is the surprise: a small eigenvalue guarantees a cheap cut, and the proof finds it. Start from the eigenvector, y, whose quotient is lambda two. Lay its entries on a line. Find the point c where the volume on either side is at most half, and shift everything by c. That leaves the numerator alone and only grows the denominator. Now split the shifted vector into its positive and negative parts. Across any edge, the two parts' squared differences add up to at most the original one, so one of the parts has a quotient no bigger than lambda two. Call it z: never negative, living on at most half the volume, with quotient at most lambda two.

Scale z so its largest entry is one, pick t uniformly between zero and one, and keep the vertices whose squared value is at least t. A vertex is kept with probability z i squared, and an edge is cut when t falls between its two ends' squares. So the expected number of cut edges is a sum of differences of squares, which Cauchy–Schwarz splits into two square roots: the first is the numerator of z's quotient, and the second at most root two times its denominator. The expected volume is exactly that denominator. So, on average, cut edges over volume is at most the square root of twice lambda two. Some threshold must do at least as well as the average, and every threshold set is a stretch at one end of the Fiedler order. So some sweep cut meets the bound.

So the algorithm is simple. Sort the vertices by their entry in the eigenvector. Take the first vertex, then the first two, then three, and compute the conductance of each prefix, updating the cut as each vertex crosses over. Keep the best. On our small graph the best prefix is the first six, the cut between the clusters. On chapter two's graph of a hundred and twenty vertices, the conductance curve dips to its minimum at sixty: exactly the planted split. One eigenvector, one sort; and Cheeger's inequality guarantees the answer is never far from the best possible, measured on the square-root scale.

4Random walks and mixingResearch5 min

Random walks, and how fast they mix. Put a walker on a vertex and let it step to a random neighbour, again and again, and follow the probability of where it is. At each step every vertex splits its probability equally among its neighbours: multiply by D inverse A. Start with all the mass on one vertex at the far left, and watch it spread: first through its own cluster, then, slowly, across the two bridges. Where does it settle? Try giving each vertex mass proportional to its degree, d i over twice the number of edges. One step sends each neighbour exactly its share back, and the degrees reappear: this distribution does not change. It is stationary, and on a connected graph that is not bipartite, every start converges to it.

On a bipartite graph, such as this cycle of eight, the walker alternates sides: all the mass on the even vertices, then all on the odd ones, for ever. It never settles. The cure is laziness. At each step, stay put with probability one half, and otherwise move. Now the mass spreads and settles. Conjugate the lazy walk by the square root of the degrees: what appears is one half of the identity plus the rescaled adjacency matrix, which is the identity minus half of the normalized Laplacian. So the lazy walk's eigenvalues are one minus half of N's: all between zero and one, the top one exactly one, and the next one minus half of lambda two, the spectral gap.

Here is why the gap sets the speed. Write the starting distribution in the eigenvectors of the lazy walk. Each step multiplies the component along the i-th eigenvector by mu i. The first component, with mu one equal to one, is the stationary distribution itself, and it stays. Run the walk, and every other component decays geometrically. The last to go is the second, which shrinks by only one minus half the spectral gap per step. On this graph the two bridges make the gap small, so that one mode, the imbalance between the two clusters, lingers long after the rest have gone.

Measure the distance from stationarity by total variation, half the sum of the differences, and define the mixing time as the first step at which that distance is at most a quarter, from any start. Every mode except the stationary one shrinks by at least one minus half the gap per step, and Cauchy–Schwarz converts the result into total variation, at the cost of the square root of one over the smallest stationary probability. One minus x is at most e to the minus x, so the walk mixes within one over the gap, times the logarithm of four over that smallest probability. And the slowest mode forces at least about two over the gap steps, times the logarithm of two. So, up to a logarithm, the mixing time is one over the spectral gap.

Now measure. Four graphs on sixty-four vertices: a cycle, an eight by eight grid, a random graph in which every vertex has four neighbours, and a barbell, two dense cliques joined by a single edge. Start a lazy walk at one vertex of each. The random graph mixes in fifteen steps and the grid in fifty-one; the cycle and the barbell are still far away after three hundred. Their spectral gaps tell the same story before any walking is done, and every mixing time we could measure falls between the two bounds. The barbell's gap is the smallest of all, though it has the most edges: one bridge is a cut of tiny conductance, and by Cheeger's inequality, a tiny conductance forces a tiny gap.

PageRank, from Part 18, is a random walk with a restart. With probability eighty-five hundredths the surfer follows a random link; otherwise it jumps to a page chosen uniformly. The jump buys a spectral gap: Taher Haveliwala and Sepandar Kamvar showed in 2003 that no other eigenvalue of this matrix is larger in size than the damping factor. So power iteration's error shrinks by at least that factor every step. On Part 18's random web of twenty thousand pages, the change per step fell faster still, by about fifty-eight hundredths a step, reaching ten to the minus twelve in fifty-two steps. Random links make a graph that mixes fast: the next chapter's expanders.

5ExpandersResearch4 min

Expanders: graphs that are sparse, and yet impossible to cut. What makes a graph an expander? Take the Petersen graph, ten vertices of degree three, and pick the outer five. Edge expansion counts the edges leaving a set, per vertex: here five leave five, a ratio of one, and no set of at most half the vertices does better. Vertex expansion counts the new neighbours a set reaches: all five inner ones. Spectral expansion asks that every eigenvalue but the top one, d, be small in size: here three, one and minus two, so lambda is two. Cheeger's inequality from chapter three, rescaled for degree d, ties the first to the third: a wide gap below d means no cheap cut. Keep that gap as the graphs grow, and they form a family of expanders.

Take any two sets of vertices, S and T, and count the edges between them. A random graph of the same degree would have about d times S times T over n. The expander mixing lemma says that an expander comes close to that for every pair of sets at once: the error is at most lambda times the square root of the product of their sizes. Read it in densities: the fraction of edges running from S to T is the product of the two densities, up to lambda over d. A small lambda makes a fixed, sparse graph look random to every large set.

Write the count as the indicator of S, times A, times the indicator of T. Split each indicator into its average, a multiple of the all-ones vector, and a remainder orthogonal to it. Expand. A sends all ones to d times all ones, so both cross terms vanish. All ones, A, all ones is the sum of the degrees, and the first term is exactly the random graph's count. The rest is the error. A keeps vectors orthogonal to all ones and stretches them by at most lambda, so by Cauchy–Schwarz the error is at most lambda times the two remainders' lengths, each shorter than its indicator. That is the lemma.

How small can lambda be? Compare any regular graph with the infinite tree of degree d. The trace of A to the two k counts closed walks, and equals the sum of the eigenvalues to that power: d to the two k from the top one, at most lambda to the two k from each other. But every vertex has at least the tree's closed walks: a Catalan number of shapes, with at least d minus one choices per step out. Combine, take k a small multiple of log n, and lambda can fall below twice the square root of d minus one by only a vanishing amount. That is the Alon–Boppana bound. Graphs that meet it are Ramanujan graphs; Lubotzky, Phillips and Sarnak built the first families in 1988.

Now measure. One random regular graph on four hundred vertices for each of five degrees, from three to twelve. The top eigenvalue is always d; the yellow curve is the Ramanujan bound. Every measured lambda sits just below it: two point eight two against two point eight three at degree three, six point four two against six point six three at degree twelve. Coin flips come close to the best possible; chapter eleven says why. And the mixing lemma, on two hundred random pairs of sets: the worst error is from about a fifth to about a third, far inside lambda.

6Explicit expanders: the zig-zag productResearch5 min

Chapter five ended on a problem. Explicit means a short program that, given a vertex as a string of bits and an edge label, returns the neighbour in time polynomial in the string's length. The first family came from Grigory Margulis in 1973: the vertices are pairs of numbers modulo m, and the neighbours come from a few fixed linear maps. His proof gave no explicit constant; Ofer Gabber and Zvi Galil supplied one in 1981, and the Ramanujan graphs of Lubotzky, Phillips and Sarnak rest on deep number theory. In 2000 Omer Reingold, Salil Vadhan and Avi Wigderson found a construction with a proof a page long.

Take a big graph G, here five vertices of degree four, and a small graph H with one vertex per edge at a vertex of G: a four-cycle. Replace every vertex of G by a cloud, a copy of H whose points are the ports where G's edges attach. A vertex of the product is a cloud and a port. An edge is three moves. Zig: a step of H inside the cloud. The big step: leave along G's edge at that port. Zag: one more step of H, in the new cloud. Two choices for the zig, two for the zag: degree four, whatever G's degree. Ours is larger: G of degree eight on sixty vertices, H of degree three on eight, four hundred and eighty vertices of degree nine.

Write one step as three matrices: a step of H in every cloud, the big step, which only permutes ports, and another step of H. H is an expander, so its step is nearly a jump to a uniform port: one minus lambda H of that jump, plus lambda H of a matrix of norm at most one. Multiply out. One term uses the uniform jump on both sides; the other three together are no bigger than their weight. That one term is G's own walk: average over a cloud, take G's edge from a random port, average again. Orthogonal to the uniform vector, it shrinks by lambda G. So lambda of the product is at most a mixture of lambda G and one. Rearranged: the product's gap is at least G's gap times one minus lambda H, squared: shrunk by a fixed factor, never closed.

Now the product we built. G, of degree eight, has normalized lambda about two thirds; H, of degree three on eight vertices, about three quarters. The product measures eighty-one hundredths: a real expander, of degree nine. The sharper bound of Reingold, Vadhan and Wigderson promises at most ninety-one hundredths; the gap bound we proved, ninety-eight. Their simplest bound, lambda G plus lambda H plus lambda H squared, is almost two here and says nothing. It is meant for an H with a small lambda.

Now the construction. Fix one small expander H with D to the fourth vertices, degree D, and lambda at most a fifth. Being of constant size, it can be found by search. Then alternate: square, which squares lambda but multiplies the degree, and zig-zag with H, which brings the degree back. If G t has degree D squared and lambda at most two fifths, its square has degree D to the fourth, exactly the size of H, and lambda at most four twenty-fifths. The zig-zag adds a fifth and a twenty-fifth, which makes two fifths again: the same guarantee, on D to the fourth times as many vertices. One refinement, tensoring two half-size graphs before squaring, makes each neighbour cost time polynomial in log N.

It paid off in 2005. In an undirected graph, is t reachable from s? Breadth-first search remembers every vertex it has seen. A random walk needs only logarithmic memory, as Aleliunas and coauthors showed in 1979, but it needs coins. Omer Reingold removed them: repeat a round of zig-zag with a small fixed expander and a few squarings. Each round keeps the degree constant and at least doubles the spectral gap, until it is a constant. A connected graph starts with a gap of at least one over a polynomial in N, so logarithmically many rounds make every component an expander, of diameter order log N. Then try every walk of that length from s: a list of constant-size labels, in logarithmic memory. Symmetric logspace equals logspace.

7Expanders at workIndustry4 min

Expanders at work: saving random bits, correcting errors, and proving theorems. Parts 20 and 27 amplified randomized algorithms by rerunning them. Suppose an algorithm reads r random bits, and only a bad set, at most half of the strings, can fool it. Independent runs all fail with probability a half to the number of runs, but each run costs r new bits. Instead, put all two to the r strings on an explicit expander of constant degree. Pick a random start, then walk: each step costs only the logarithm of the degree. The samples are no longer independent. How likely is it that all land in B?

Start uniform. Each step moves with the walk matrix M, then keeps only the mass on B, with the projection P; what is left is the chance that every sample was bad. Look at one step. Split a vector x living on B into its part along the all-ones vector and the rest; M leaves the first alone. The first is small because B is: Cauchy–Schwarz bounds it by mu times x. The rest shrinks by lambda. So each step costs a factor mu plus lambda, and all the samples land in B with probability at most mu times mu plus lambda to the t. Averages work too: David Gillman proved a Chernoff bound for such walks in 1998.

What does it buy? Take an algorithm with two hundred and fifty-six random bits and a bad half, and an expander with lambda a quarter and degree two to the ten: ten bits a step. Each step multiplies the failure bound by three quarters. For an error of two to the minus twenty, independent runs need five thousand one hundred and twenty bits; the walk needs forty-six steps, seven hundred and sixteen bits. The walk pays a constant for each halving of the error; fresh runs pay the full r.

Part 28 drew parity-check codes as graphs of bits and checks, after Michael Tanner in 1981. Here is a toy: twelve bits, each in three checks. In 1996 Michael Sipser and Daniel Spielman asked what expansion buys. Take a small set S of bits. A check is a unique neighbour if exactly one edge from S reaches it. Each unique check takes one of S's edges, and each shared check at least two. If small sets reach more than three quarters of their edges' worth of checks, more than half of S's edges end at unique checks. So a nonzero word on a small set fails a check: it is not a codeword, and the distance is large.

Expansion also gives a decoder. Send all zeros; two bits arrive flipped. Every check on an odd number of wrong bits is unsatisfied: four of them. The rule: flip any bit with more than half of its checks unsatisfied. The first wrong bit qualifies; flip it, and three unsatisfied checks remain. Now the second has all three of its checks unsatisfied; flip it, and every check is happy. On a good enough expander, Sipser and Spielman proved, this always works for errors up to a fixed fraction of the length: some wrong bit always qualifies, and each flip lowers the count: linear time.

8Graphs as electrical networksResearch5 min

Part 3 built logic from switches driven by voltages; now circuits return as mathematics. Make every edge of a graph a resistor, and give each vertex a voltage. Ohm's law: the current along an edge is its conductance times the voltage drop across it. Kirchhoff's law: the current leaving a vertex, summed over its edges, equals the current injected there from outside. Put Ohm into Kirchhoff. Expand: the vertex's voltage times its weighted degree, minus its neighbours' voltages. That is one row of the Laplacian. All the rows together say L x equals b: voltages in, injected currents out. Gustav Kirchhoff wrote these equations down in 1847.

Now drive the circuit. Inject one amp at s and draw it out at t: b is plus one at s and minus one at t. Its entries sum to zero, which is exactly what a Laplacian system needs to be solvable. The voltages are L's pseudo-inverse applied to b, up to a constant, so set t to zero, and colour each vertex by its voltage. Current runs downhill along every edge, thick where the drop is large. And at every inner vertex what flows in flows out: forty-five hundredths in here, nine and thirty-six hundredths out.

How hard is it to push current from s to t? The effective resistance is the voltage it takes to push one amp. Read that voltage difference with the vector e s minus e t, which is b itself, while the voltages are L plus b: a quadratic form in the Laplacian's pseudo-inverse. It is also the energy the current burns: chapter one's sum of squared differences, at the voltages, collapses to the same form. Check it on circuits you know: two one-ohm resistors give two in series and a half in parallel. Our nine-resistor circuit comes to about one point three six.

Which of all the ways to send one unit from s to t does current choose? Give each unit flow an energy: resistance times flow squared, summed over the edges. Write any flow as the electrical flow plus a circulation, balanced at every vertex. The cross term vanishes: by Ohm's law it is voltage drops times the circulation, and regrouped by vertex, each voltage multiplies a net flow of zero. So the electrical flow has the least energy, and that energy is the effective resistance: Thomson's principle. Splitting the unit over two paths costs one and a half; one path, three. A corollary: lowering any resistance cannot raise the effective resistance.

Now let a random walker loose. Its commute time is the expected number of steps from s to t and back. Let phi of u be the expected time to reach t from u: one step, then the neighbours' average. Multiply by the degree, and it is a Laplacian system: the degrees injected, all of two m drawn out at t. Hitting times to s, called psi, satisfy the same. Subtract: the degrees cancel, and phi minus psi is two m times the voltages of one amp. Read at s and t: the commute time is two m times the effective resistance, as Chandra, Raghavan, Ruzzo, Smolensky and Tiwari proved in 1989. Doyle and Snell's book of 1984 had already joined walks and circuits.

Test it. A five by five grid has forty edges. Corner to corner its effective resistance is about two point one four, so the formula predicts a commute time of about a hundred and seventy-one steps. Here is one walker, wandering. Two thousand simulated round trips averaged a hundred and seventy-four, within sampling error. A question about wandering has become one Laplacian system.

One classic from Doyle and Snell's book. George Pólya proved in 1921 that a random walk on the square lattice surely returns home; on the cubic lattice it may not. In circuit terms: it surely returns exactly when the resistance from the origin to infinity is infinite. In the plane, short each square shell into one node; by Rayleigh, that only lowers the resistance. What is left is bundles of four, twelve, twenty edges in parallel, joined in series. One over eight k plus four sums to infinity, so the walker comes home. In three dimensions a current spread over shells of about k squared edges has finite energy, so by Thomson the resistance is finite.

9Laplacian solvers and sparsifiersResearch5 min

Laplacian solvers, and the sparse graphs that make them fast. Everything that follows needs to solve L x equals b fast. Gaussian elimination costs cubic time and, as Part 52 showed, fills a sparse matrix in. Conjugate gradients do better. The k-th iterate is built from b, L b, L squared b and so on: k multiplications by L. And L to the j times b is non-zero only within j hops. Watch it on a path, with current in at one end and out at the other. The answer is a straight ramp, but each iteration extends it by one vertex from each end. In general the iterations grow like the square root of the condition number, the largest eigenvalue over lambda two. Long, thin graphs are badly conditioned; expanders are not.

The cure for bad conditioning is preconditioning: solve with a nearby matrix that is easier, and let conjugate gradients correct the difference. For Laplacians, the natural nearby matrix is the Laplacian of a sparser graph H, whose quadratic form stays within one plus or minus epsilon of G's for every vector x at once: every energy, and so every cut. Spielman and Teng called such an H a spectral sparsifier. Then the preconditioned system has all its eigenvalues near one. Our test graph has three hundred vertices and thirteen thousand six hundred and fifty-seven edges. Its sparsifier keeps one thousand five hundred and ninety-one, and conjugate gradients drop from sixty-seven iterations to fourteen.

Which edges can a sparsifier drop? Two cliques of eight, joined by one bridge. Colour each edge by its effective resistance. The bridge has resistance one: it is the only way across, and every cut between the cliques depends on it. An edge inside a clique has a quarter: plenty of other routes do its job. And the total is fixed. Each resistance is a quadratic form; gather them into one trace; the weighted resistances of a connected graph's edges sum to n minus one. This is Foster's theorem, from 1949. Resistance is a budget of importance, n minus one in all, however many edges there are.

In 2008 Daniel Spielman and Nikhil Srivastava turned that budget into an algorithm. Sample edges with probability proportional to weight times effective resistance. Draw q of them, each drawn edge weighted by one over q times its probability. On average the sample's Laplacian is exactly G's. With about n log n over epsilon squared draws, a matrix concentration inequality makes it right within one plus or minus epsilon, with high probability. Forty draws from our two cliques keep the bridge and thin the cliques; uniform draws would miss the bridge half the time, and with it every path between the halves. Joshua Batson, Spielman and Srivastava then showed that a linear number of edges always suffices. For the complete graph their sparsifiers match Ramanujan expanders with twice as many edges: twice-Ramanujan sparsifiers.

But computing an effective resistance means solving a Laplacian system, and we want all m of them. Rewrite the quadratic form. Insert L between two pseudo-inverses, and factor L through the edge-vertex incidence matrix. Now each resistance is a squared distance between two columns of one matrix. Distances survive random projection: this is the Johnson–Lindenstrauss lemma from AI, Built and Part 20's sketches. A random matrix with about log n rows keeps every one of these distances within one plus or minus epsilon. So log n Laplacian solves give every resistance at once. The circle, sparsifiers needing resistances needing solvers, was broken by a solver that came first.

The simplest sparse graph is a spanning tree. Lay a snake-shaped tree on a grid. An edge it leaves out must be replaced by its path through the tree; that path's length is the edge's stretch, here eleven. The tree is part of the graph, and each edge costs at most its stretch times its tree path, so the condition number is at most the total stretch. And a tree system is solved in linear time, by peeling off leaves. A tree with a central spine stretches less, and conditions better. Spielman and Teng, in 2004, built a recursion from low-stretch trees and sparsifiers: precondition by a tree plus a few edges, eliminate vertices of degree one and two, recurse. Laplacian systems became solvable in nearly linear time.

10From electrical flows to max-flowResearch5 min

Part 18 met maximum flow: push as much as possible from s to t without exceeding any edge's capacity, and it solved the problem with augmenting paths. Here is a network with capacities from one to four; its maximum flow is four. Electrical flow is tempting, because one Laplacian solve, in nearly linear time, routes the whole value at once, spread over every path. Give each edge resistance one over its capacity squared, so wide edges conduct well. But current knows nothing of capacities. The edge from s to a has capacity two and is asked to carry almost three: congestion one point four one.

Current breaks capacities, but not by much on average, and the reason is Thomson's principle. Give each edge a weight, starting at one, and resistance weight over capacity squared. Suppose some flow of value F fits the capacities. The electrical flow's energy is no more than that flow's, which is at most the sum of the weights. Write the electrical energy out edge by edge, and it says: the weighted average of squared congestion is at most one. A few edges can overflow, but only a few. Our first electrical flow overflows one edge by forty-one percent, while the weighted mean of squares is far below one.

So use the overflow to adjust the weights. Compute an electrical flow; raise the weight, and so the resistance, of every edge in proportion to its congestion; and repeat, averaging the flows. Edges that overflow become expensive, and the next current avoids them. This is the multiplicative weights method of Part 23, with an electrical flow as the expert's move. Round by round, the worst congestion of the average falls, from one point four one towards one. After thirty rounds, shrink the averaged flow until it fits: it carries ninety-seven percent of the maximum. In 2011 Paul Christiano, Jonathan Kelner, Aleksander Mądry, Daniel Spielman and Shang-Hua Teng refined this loop into the fastest algorithm then known for approximate maximum flow in undirected graphs.

The other road from circuits to flows runs through interior-point methods, met in Part 23 with Karmarkar. Maximum flow is a linear program. Replace the hard capacity limits by a logarithmic barrier that rises to infinity at either limit. Each Newton step minimizes a quadratic model, a linear term plus a weighted sum of squares, under flow conservation. That is the energy of an electrical flow, each edge's resistance the curvature of its barrier, which explodes as the edge fills. So each step is one Laplacian solve, and current steers around full edges by itself. About the square root of m steps gave exact flows in about m to the three halves; the next decade went into cutting the steps.

In 2022 Li Chen, Rasmus Kyng, Yang Liu, Richard Peng, Maximilian Probst Gutenberg and Sushant Sachdeva took the last step. An electrical step spreads a small change over every path, and needs a fresh solve each time. They replaced it by its cousin in another norm: the circulation with the best ratio of gain to length, and the best one is a single cycle. Lay down a spanning tree: every edge outside it closes exactly one cycle, and when the tree has low stretch, one of those cycles is within a modest factor of the best. Their method takes m to the one plus little o of one steps, and dynamic data structures keep the trees current, at m to the little o of one per step. The result: exact maximum flow and minimum-cost flow on directed graphs, in almost linear time.

Step back and look at the exponent. In 1972 Edmonds and Karp's augmenting paths took n times m squared steps, cubic on sparse graphs. In 1998 Andrew Goldberg and Satish Rao reached about m to the three halves. Electrical flows broke that barrier in 2011 for approximate flows in undirected graphs, and in 2022 the exponent reached one, for exact flows in directed graphs. The road ran from Kirchhoff's equations, through fast Laplacian solvers, electrical flows and interior points, to cycles on low-stretch trees. The algorithm is still far too intricate to run in practice, which the frontier chapter lists among the open problems.

11Frontier: high-dimensional expandersResearch2 min

What happens when triangles, and not just edges, have to expand? An expander is a graph in which every set of vertices has many edges leaving it. A high-dimensional expander asks the same of a complex: vertices, edges and triangles, glued together. Around each vertex, the triangles that touch it form a small graph called its link. A complex is a high-dimensional expander when it is connected and every link is itself an expander. The surprise is a local-to-global principle, going back to Howard Garland in 1973 and sharpened in the last decade: if every link expands enough, then random walks that move from triangle to triangle mix fast across the whole complex. Unlike ordinary expanders, bounded-degree examples are not found by drawing at random; the known constructions come from deep algebra.

In a few years high-dimensional expanders have settled old questions. In 2019 Nima Anari, Kuikui Liu, Shayan Oveis Gharan and Cynthia Vinzant proved that a simple random walk samples the bases of any matroid quickly, settling a conjecture of Mihail and Vazirani, and spectral independence then carried the method to models from statistical physics. In 2022 two groups built locally testable codes with constant rate, distance and locality, and good quantum low-density codes of the kind Part 53 needed. And Irit Dinur's proof of the PCP theorem, from Part 27, already amplified gaps with expanders; higher-dimensional ones are a route to stronger versions. In each case, expansion turns a local check into a global guarantee.

How small can a regular graph's second eigenvalue be? Alon and Boppana showed it cannot go below two times the square root of d minus one, in the limit. Graphs that reach the bound are called Ramanujan graphs. Our random regular graphs from chapter five sit just under the curve, and Joel Friedman proved in 2008 that random regular graphs come within any margin of it. In 2015 Adam Marcus, Daniel Spielman and Nikhil Srivastava proved that bipartite Ramanujan graphs exist for every degree, with a new method, interlacing families of polynomials, that also solved the Kadison–Singer problem.

Recap, problems, and where this comes backAll tracks2 min

What we built in this part. The Laplacian, whose quadratic form is the energy of a labelling, and whose second eigenvalue says how connected a graph is. The Fiedler vector and the sweep cut, with Cheeger's inequality to guarantee them. Random walks whose mixing time is set by the spectral gap. Expanders, random and Ramanujan, and the zig-zag product that builds them explicitly. Graphs as electrical networks, where commute times are resistances, and the sparsifiers and solvers that led to maximum flow in almost linear time. One idea runs through it: a graph's eigenvalues summarize its global shape in a handful of numbers.

Where this comes back. Part 58 meets fixed points again, in the meaning of programs. Part 59 runs algorithms on graphs where each node sees only its neighbourhood, and proves how far that sight must reach. And Part 61 puts this part's open problem, the unique games conjecture, on the map of what is still unknown.

In practice. Spectral clustering embeds a graph by its bottom eigenvectors and then clusters the points. Multilevel partitioners split graphs for sharding and for parallel computation. PageRank is a random walk with a restart. Data-centre networks have been built on expander-like topologies. And Laplacian systems are solved every day with preconditioned conjugate gradients and multigrid.

Six problems, with full solutions in the part's notes. Pause on any of them. The fifth is a build problem: construct a zig-zag product yourself and check its second eigenvalue against the bound of Reingold, Vadhan and Wigderson. The last, marked with a star, is a research problem: whether telling if small sets expand is hard.

Next time, Part 57: learning theory. When can a machine learn from examples, how many examples does it need, and why do enormous neural networks generalize at all, when the classical theory says they should not?

The books and papers this part follows are on screen and in the notes. Thank you for watching.

Where it goes next. Part 58 meets fixed points again, in the meaning of programs. Part 59 runs algorithms on graphs where each node sees only its neighbourhood. Part 61 puts the unique games conjecture, which small-set expansion sits beside, on the map of open problems.

Key results

The part's results in one place, for revision.

The Laplacian's energy\(\displaystyle x^{\mathsf T}Lx=\sum_{\{i,j\}\in E}(x_i-x_j)^2,\qquad\allowbreak \lambda_2=\min_{x\perp\mathbf 1}\frac{x^{\mathsf T}Lx}{x^{\mathsf T}x}\)
Cheeger's inequality\(\displaystyle \frac{\lambda_2}{2}\ \le\ \phi(G)\ \le\ \sqrt{2\lambda_2}\qquad\allowbreak (\lambda_2 \text{ of } I-D^{-1/2}AD^{-1/2})\)
Mixing of the lazy walk\(\displaystyle \|p_t-\pi\|_{TV}\ \le\ \tfrac12\sqrt{1/\pi_{\min}}\,\bigl(1-\tfrac{\lambda_2}{2}\bigr)^{t}\)
Expander mixing lemma\(\displaystyle \Bigl|e(S,T)-\frac{d\,|S|\,|T|}{n}\Bigr|\ \le\ \lambda\sqrt{|S|\,|T|},\qquad\allowbreak \lambda\ \ge\ 2\sqrt{d-1}-o(1)\)
Zig-zag product Z of G and H\(\displaystyle 1-\lambda_{Z}\ \ge\ (1-\lambda_H)^2\,(1-\lambda_G)\)
Commute time\(\displaystyle C(a,b)=2m\,R_{\text{eff}}(a,b),\qquad\allowbreak R_{\text{eff}}(a,b)=(e_a-e_b)^{\mathsf T}L^{+}(e_a-e_b)\)

Try it

Lab 56 · What the second eigenvalue promises: cuts, walks and expanders

On random 12-vertex graphs compare the best conductance over all 2,047 cuts with lambda_2 / 2 and sqrt(2 lambda_2) and with the sweep cut; on four 64-vertex graphs compare the lazy walk's distance from stationarity with the spectral bound; and measure random regular graphs against 2 sqrt(d - 1).

Figure produced by Lab 56: What the second eigenvalue promises: cuts, walks and expanders
Produced by the lab below, seed 0, in 0.6 s.
python -m videos.cs.labs 56 needs numpy, scipy, matplotlib · download lab56.py · source on GitHub
23 connected random graphs on 12 vertices  all inside lambda2/2 <= phi <= sqrt(2 lambda2); the sweep cut is the best cut in 15
closest to the lower bound                 phi = 0.429 against lambda2/2 = 0.377 and sqrt(2 lambda2) = 1.228
random 4-regular: gap 0.1654               t_mix = 16   (bounds from the gap: 8 to 34)
8 x 8 grid: gap 0.0463                     t_mix = 51   (bounds from the gap: 29 to 132)
cycle: gap 0.0048                          t_mix = 389   (bounds from the gap: 287 to 1152)
random 3-regular graph on 200 vertices     lambda = 2.850   2 sqrt(d - 1) = 2.828   worst mixing-lemma error 0.26 (at most lambda)
random 4-regular graph on 200 vertices     lambda = 3.455   2 sqrt(d - 1) = 3.464   worst mixing-lemma error 0.29 (at most lambda)
random 8-regular graph on 200 vertices     lambda = 5.282   2 sqrt(d - 1) = 5.292   worst mixing-lemma error 0.43 (at most lambda)

The second eigenvalue brackets the best cut from both sides, sets how fast a walk mixes, and for a random regular graph sits near 2 sqrt(d - 1), as small as any large d-regular graph allows.
The code (95 lines; it asserts its own result)
"""Lab 56: check Cheeger's inequality against every cut of small graphs, and a walk's mixing against the spectral gap."""

from videos.coursekit import labs  # noqa: I001  (must stay first: it lets explainer.cs import without manim)

import math

import numpy as np

from explainer.cs.spectral import spectra

TITLE = "What the second eigenvalue promises: cuts, walks and expanders"
GOAL = ("On random 12-vertex graphs compare the best conductance over all 2,047 cuts with lambda_2 / 2 and "
        "sqrt(2 lambda_2) and with the sweep cut; on four 64-vertex graphs compare the lazy walk's distance from "
        "stationarity with the spectral bound; and measure random regular graphs against 2 sqrt(d - 1).")
TASKS = [
    "Replace the 12-vertex random graphs by spectra.cycle(12) and by the hypercube Q_3 with a pendant path. Which side of Cheeger's inequality does each come close to?",
    "Add spectra.barbell(32) with 2,000 steps to the mixing panel. Which vertex set is the bottleneck, and how does its conductance compare with the gap?",
    "Build spectra.zigzag(G, H) for a random 8-regular G on 60 vertices and a random 3-regular H on 8, and compare its second eigenvalue with 1 - (1 - lambda_H)^2 (1 - lambda_G).",
]

N = 64


def worst_start(A, steps):
    """The lazy walk's total-variation distance from stationarity, maximized over the starting vertex, per step."""
    d = A.sum(axis=1)
    W = 0.5 * (np.eye(len(A)) + A / d[:, None])
    pi = d / d.sum()
    P, out = np.eye(len(A)), []
    for _ in range(steps + 1):
        out.append(float(0.5 * np.abs(P - pi).sum(axis=1).max()))
        P = P @ W
    return np.array(out), pi


def run(seed=0):
    lab = labs.Lab()

    # 1. Cheeger on graphs small enough to try every cut
    rows = spectra.cheeger_check(trials=24, seed=seed)
    assert len(rows) >= 12
    for r in rows:
        assert r["lower"] - 1e-9 <= r["phi"] <= r["sweep"] + 1e-9 <= r["upper"] + 2e-9, "lambda2/2 <= phi <= sweep <= sqrt(2 lambda2)"
    exact = sum(abs(r["sweep"] - r["phi"]) < 1e-9 for r in rows)
    tight = min(rows, key=lambda r: r["phi"] / r["lower"])
    lab.row(f"{len(rows)} connected random graphs on 12 vertices", f"all inside lambda2/2 <= phi <= sqrt(2 lambda2); "
            f"the sweep cut is the best cut in {exact}")
    lab.row("closest to the lower bound", f"phi = {tight['phi']:.3f} against lambda2/2 = {tight['lower']:.3f} "
            f"and sqrt(2 lambda2) = {tight['upper']:.3f}")

    # 2. the lazy walk against the gap, from the worst starting vertex
    graphs = {"random 4-regular": (spectra.random_regular(N, 4, seed=seed + 1), 80),
              "8 x 8 grid": (spectra.grid(8, 8), 250), "cycle": (spectra.cycle(N), 1400)}
    curves = {}
    for name, (A, steps) in graphs.items():
        gap = float(np.linalg.eigvalsh(spectra.laplacian(A, True))[1])
        tv, pi = worst_start(A, steps)
        bound = 0.5 * math.sqrt(1 / pi.min()) * (1 - gap / 2) ** np.arange(steps + 1)
        t_mix = int(np.argmax(tv < 0.25))
        lo, hi = (2 / gap - 1) * math.log(2), math.log(4 / pi.min()) / gap
        assert tv[t_mix] < 0.25 and np.all(tv <= bound + 1e-12), "the walk is under the spectral bound at every step"
        assert lo <= t_mix <= hi, "the mixing time lies between the two bounds the gap gives"
        curves[name] = (tv, bound)
        lab.row(f"{name}: gap {gap:.4f}", f"t_mix = {t_mix}   (bounds from the gap: {lo:.0f} to {hi:.0f})")

    # 3. random regular graphs against the Alon-Boppana limit
    spec = spectra.regular_spectra(n=200, ds=(3, 4, 8), seed=seed)
    for r in spec:
        assert abs(r["lambda"] / r["ramanujan"] - 1) < 0.08 and r["mixing_worst"] <= r["lambda"] + 1e-9
        lab.row(f"random {r['d']}-regular graph on 200 vertices", f"lambda = {r['lambda']:.3f}   2 sqrt(d - 1) = "
                f"{r['ramanujan']:.3f}   worst mixing-lemma error {r['mixing_worst']:.2f} (at most lambda)")
    lab.note = ("The second eigenvalue brackets the best cut from both sides, sets how fast a walk mixes, and for a "
                "random regular graph sits near 2 sqrt(d - 1), as small as any large d-regular graph allows.")

    fig, ax = labs.figure(2, size=(11, 4.3))
    lam = np.linspace(0.001, max(r["lambda2"] for r in rows) * 1.08, 200)
    ax[0].plot(lam, np.sqrt(2 * lam), color=labs.RED, label="sqrt(2 lambda2)")
    ax[0].plot(lam, lam / 2, color=labs.GREEN, label="lambda2 / 2")
    ax[0].scatter([r["lambda2"] for r in rows], [r["sweep"] for r in rows], s=34, facecolors="none",
                  edgecolors=labs.GOLD, label="sweep cut")
    ax[0].scatter([r["lambda2"] for r in rows], [r["phi"] for r in rows], s=12, color=labs.BLUE, label="best of all 2,047 cuts")
    ax[0].set(title="Cheeger's inequality on random 12-vertex graphs", xlabel="lambda2 of the normalized Laplacian",
              ylabel="conductance")
    ax[0].legend(loc="upper left")
    for (name, (tv, bound)), color in zip(curves.items(), (labs.BLUE, labs.GOLD, labs.PURPLE)):
        t = np.arange(len(tv))
        ax[1].loglog(t[1:], tv[1:], color=color, label=name)
        ax[1].loglog(t[1:], np.minimum(bound[1:], 1), color=color, ls="--", lw=1)
    ax[1].axhline(0.25, color=labs.MUTED, lw=1, ls=":")
    ax[1].text(1.1, 0.27, "1/4: mixed", color=labs.MUTED, fontsize=9)
    ax[1].set(title="Lazy walks: distance (solid) and bound (dashed)", xlabel="steps",
              ylabel="total variation, worst start", ylim=(1e-3, 1.5))
    ax[1].legend(loc="lower left")
    lab.fig = fig
    return lab

Now change it

  1. Replace the 12-vertex random graphs by spectra.cycle(12) and by the hypercube Q_3 with a pendant path. Which side of Cheeger's inequality does each come close to?
  2. Add spectra.barbell(32) with 2,000 steps to the mixing panel. Which vertex set is the bottleneck, and how does its conductance compare with the gap?
  3. Build spectra.zigzag(G, H) for a random 8-regular G on 60 vertices and a random 3-regular H on 8, and compare its second eigenvalue with 1 - (1 - lambda_H)^2 (1 - lambda_G).

Problems, with solutions

Try each problem before opening its solution.

  1. The energy. Show that xᵀLx = Σ_{(i,j)∈E} (x_i − x_j)², and that the multiplicity of the eigenvalue 0 equals the number of components.

    Solution

    With L = D − A, xᵀDx = Σ_i d_i x_i² = Σ_{(i,j)∈E} (x_i² + x_j²), because each edge adds one to the degree of each of its ends, and xᵀAx = Σ_{i,j} A_ij x_i x_j = 2 Σ_{(i,j)∈E} x_i x_j, because each edge appears in A as (i, j) and as (j, i). Subtracting, xᵀLx = Σ_E (x_i² + x_j² − 2x_i x_j) = Σ_E (x_i − x_j)² ≥ 0. So L is symmetric and positive semidefinite, and then xᵀLx = ‖L^{1/2}x‖² vanishes exactly when Lx = 0. The null space of L is therefore {x : x_i = x_j across every edge}, the vectors constant on each connected component (a path inside a component forces equal values along it). If the components are C₁, …, C_k, their indicator vectors have disjoint supports, so they are independent, and they span that space: its dimension is k. Since L is symmetric, the algebraic multiplicity of 0 equals the dimension of its eigenspace, k. Chapter 1's two hexagons have the eigenvalue 0 twice; one bridge leaves it once and lifts the other to λ₂ = 0.20.

  2. Two spectra. Compute the Laplacian spectrum of the cycle C_n and of the hypercube Q_d.

    Solution

    Cycle: number the vertices modulo n, so L = 2I − S − S⁻¹ with S the cyclic shift. The vectors χ_k(j) = ω^{jk}, ω = e^{2πi/n}, k = 0, …, n − 1, satisfy Sχ_k = ω^k χ_k, so Lχ_k = (2 − ω^k − ω^{−k})χ_k = (2 − 2cos(2πk/n))χ_k. The n of them are orthogonal, so this is the whole spectrum: 2 − 2cos(2πk/n) for k = 0, …, n − 1, with real eigenvectors cos(2πjk/n) and sin(2πjk/n); every eigenvalue other than 0 (and 4 when n is even) occurs twice. In particular λ₂ = 2 − 2cos(2π/n) ≈ 4π²/n²; for n = 8 it is 2 − √2 ≈ 0.586, chapter 1's cycle (the tests check n = 12). Hypercube: the vertices are x ∈ {0, 1}^d, joined when they differ in one bit. For S ⊆ {1, …, d} let χ_S(x) = (−1)^{Σ_{i∈S} x_i}. Flipping bit i multiplies χ_S by −1 if i ∈ S and by 1 otherwise, so (Aχ_S)(x) = Σ_i χ_S(x ⊕ e_i) = (d − 2|S|)χ_S(x) and Lχ_S = 2|S| χ_S. The 2^d characters are orthogonal, so the spectrum is 2k with multiplicity C(d, k), k = 0, …, d: for Q₃, 0, 2, 2, 2, 4, 4, 4, 6, and λ₂ = 2 as in chapter 1. Both graphs illustrate chapter 3's tightness remarks. Q_d is d-regular, so λ₂ of N is 2/d; the half-cube {x₁ = 0} cuts 2^{d−1} edges and has volume d · 2^{d−1}, so φ ≤ 1/d = λ₂/2, and with Cheeger's lower bound φ(Q_d) = λ₂/2 exactly. For C_n with n even, λ₂(N) = 1 − cos(2π/n) ≈ 2π²/n², while φ = 2/n (every cut crosses at least two edges, and the smaller side has volume at most n): of order √λ₂. For n = 64, λ₂(N) = 0.0048 (chapter 4's gap), φ = 0.031 and √(2λ₂) = 0.098.

  3. Cheeger, the easy side. Prove λ₂/2 ≤ φ(G).

    Solution

    N = D^{−1/2}LD^{−1/2} has the eigenvalue 0 with eigenvector D^{1/2}𝟏, so by Courant–Fischer λ₂(N) is the minimum of xᵀNx/xᵀx over x ≠ 0 orthogonal to D^{1/2}𝟏. Substitute x = D^{1/2}y: the constraint becomes Σ_i d_i y_i = 0, the numerator yᵀLy = Σ_E (y_i − y_j)² and the denominator Σ_i d_i y_i². So any such y gives an upper bound on λ₂. For a set S, take y = a on S and y = −b off it, with a = 1/vol S and b = 1/vol S̄; then Σ_i d_i y_i = 1 − 1 = 0. Only the cut edges have a difference across them, a + b each, so the numerator is |E(S, S̄)|(a + b)², and the denominator is vol S · a² + vol S̄ · b² = a + b. Hence λ₂ ≤ |E(S, S̄)|(a + b) ≤ 2|E(S, S̄)|/min(vol S, vol S̄) = 2φ(S), since each of a and b is at most one over the smaller volume. This holds for every S, so for the best one: λ₂/2 ≤ φ(G). On chapter 3's two-bridge graph, λ₂ = 0.129 and φ(G) = 1/9 ≈ 0.111 by brute force over all 2,047 cuts: 0.064 ≤ 0.111 ≤ √(2 × 0.129) = 0.508.

  4. The expander mixing lemma. Prove |e(S, T) − d|S||T|/n| ≤ λ√(|S||T|).

    Solution

    Let A be the adjacency matrix of a d-regular graph on n vertices, with eigenvalues d = μ₁ ≥ μ₂ ≥ … ≥ μ_n, orthonormal eigenvectors v₁ = 𝟏/√n, v₂, …, v_n, and λ = max_{i≥2} |μ_i|. The count e(S, T) = 𝟏_Sᵀ A 𝟏_T is the number of joined pairs (s, t) with s ∈ S and t ∈ T. Write 𝟏_S = (|S|/n)𝟏 + x and 𝟏_T = (|T|/n)𝟏 + y with x, y ⊥ 𝟏 and expand. The main term is (|S||T|/n²) 𝟏ᵀA𝟏 = d|S||T|/n, since 𝟏ᵀA𝟏 = dn. The cross terms vanish: A𝟏 = d𝟏, so (|S|/n) 𝟏ᵀAy = (|S|/n) d 𝟏ᵀy = 0, and likewise xᵀA𝟏 = 0. So e(S, T) − d|S||T|/n = xᵀAy. Writing y = Σ_{i≥2} c_i v_i gives Ay = Σ_{i≥2} μ_i c_i v_i and ‖Ay‖ ≤ λ‖y‖, so by Cauchy–Schwarz |xᵀAy| ≤ λ‖x‖‖y‖. Finally ‖x‖² = ‖𝟏_S‖² − |S|²/n = |S|(1 − |S|/n) ≤ |S|, and the same for y, which gives the lemma (and, keeping the factors, the sharper λ√(|S|(1 − |S|/n)|T|(1 − |T|/n))). In chapter 5's 20-vertex example e(S, T) = 9 against 7.2; on the 400-vertex random regular graphs the worst normalized error over 200 random pairs of sets was 0.20 to 0.34, against λ from 2.82 to 6.42.

  5. Build. Build the zig-zag product of two graphs of your choice, and compare its second eigenvalue with the RVW bound.

    Solution

    Solution notes. explainer/cs/spectral/spectra.py has the pieces. H must have exactly as many vertices as G's degree D: take G = random_regular(N, D, seed) and H = random_regular(D, d, seed), cycle(D) or the complete graph on D vertices. rotation_map_regular numbers each vertex's neighbours and records, for the edge from v to its i-th neighbour w, which neighbour of w the vertex v is; zigzag(G, H) adds, for each vertex (v, a) and each pair (i, j), the edge made of a zig (a to its i-th neighbour a′ in H), the big step (port a′ of v to port b′ of w) and a zag (b′ to its j-th neighbour b in H). Check that Z is symmetric and d²-regular (as test_zigzag_regular does), then compute each λ as the second largest |eigenvalue| (np.linalg.eigvalsh) divided by the degree, and compare λ_Z with the RVW bound f(λ_G, λ_H) = ½(1 − λ_H²)λ_G + ½√((1 − λ_H²)²λ_G² + 4λ_H²), with the bound proved in chapter 6, 1 − (1 − λ_H)²(1 − λ_G), and with λ_G + λ_H + λ_H². zigzag_experiment (G random 8-regular on 60, H random 3-regular on 8) gives 480 vertices of degree 9 and λ_Z = 0.811 against 0.908, 0.978 and 1.966. With the same G and H = K₈ (λ_H = 1/7) the product has degree 49 and λ_Z = 0.681, which equals the RVW bound to the digits we printed; with G random 5-regular on 60 and H = C₅, λ_Z = 0.932 against 0.957. Two traps: a bipartite H, such as the 4-cycle in the test, has λ_H = 1, so every bound is 1, and indeed λ_Z = 1; and Z can have repeated edges and loops, which must be kept as multiplicities (the code adds one for each (i, j)). A complete answer also iterates G_{t+1} = G_t² ⓩ H and watches the degree stay at d² while λ stays bounded.

  6. ★ Research. The small-set expansion hypothesis.

    Discussion. Open. Raghavendra and Steurer (2010) conjectured that for every η > 0 there is a δ > 0 such that it is NP-hard to tell a regular graph in which some set of a δ fraction of the volume has conductance at most η from one in which every such set has conductance at least 1 − η, and showed that this hypothesis implies the unique games conjecture. Spectral methods cannot settle it directly: Cheeger's inequality certifies that some cut is cheap, but says nothing about how large its sides are, and a graph can have many eigenvalues near zero while all its small sets expand, so the bottom of the spectrum does not reveal small non-expanding sets. The evidence pulls both ways. Arora, Barak and Steurer (2010) solve small-set expansion and unique games in subexponential time, exp of a power of n that shrinks with η, by exploiting graphs with few small eigenvalues; so, if 3-SAT needs exponential time, any reduction that proves the hypothesis must blow instances up by a power that grows as η shrinks. On the other side, the 2-to-2 theorem (Khot, Minzer and Safra 2018, with Dinur and Kindler) came from proving that the non-expanding small sets of the Grassmann graph have a rigid structure. A good partial answer would solve small-set expansion in polynomial time on a natural class of graphs beyond those with few small eigenvalues, prove that a fixed level of a hierarchy such as sum-of-squares fails on some family of small-set expansion instances, or give a reduction from small-set expansion to a problem not yet known to be equivalent to it.

Notes and sources

Glossary

  • Laplacian L = D − A, normalized Laplacian N, quadratic form (energy) — the matrix whose form is the sum of squared differences across the edges; its degree-weighted version, with eigenvalues in [0, 2].
  • algebraic connectivity, Fiedler vector, Fiedler order — λ₂ of L; its eigenvector; the vertices sorted by it.
  • Rayleigh quotient, Courant–Fischer theorem — energy over length; eigenvalues as min-max of the quotient.
  • minimum bisection, relaxation, spectral clustering, multilevel partitioning (METIS) — the best balanced cut; allowing real values; clustering points embedded by bottom eigenvectors; coarsen, cut, refine.
  • volume, conductance φ, sweep cut, Cheeger's inequality — the sum of degrees; cut edges over the smaller volume; the best prefix of the Fiedler order; λ₂/2 ≤ φ ≤ √(2λ₂).
  • random walk, stationary distribution, lazy walk, spectral gap γ, total variation, mixing time — a step to a random neighbour; π = d/2m; staying put half the time; λ₂ of N; half the L¹ distance; the first t with TV ≤ ¼.
  • expander (edge, vertex, spectral expansion), expander mixing lemma — a sparse graph in which every set has many edges leaving it; edges between any two sets as in a random graph, up to λ√(|S||T|).
  • Alon–Boppana bound, Ramanujan graph — λ ≥ 2√(d − 1) − o(1); a graph that meets it.
  • explicit construction, rotation map, zig-zag product, SL = L — a neighbour function computable in poly(log N); edge labels at both ends; a step in a cloud, a step between clouds, a step in a cloud; undirected reachability in logarithmic space.
  • expander walk sampling, hitting bound, Tanner graph, unique neighbour, expander code, flip decoding — reusing random bits along a walk; μ(μ + λ)^t; bits joined to the checks they take part in; a check hit once; the code of an expanding Tanner graph; flipping bits with mostly unsatisfied checks.
  • gap amplification — Dinur's rounds that double the fraction of violated constraints.
  • effective resistance, pseudo-inverse L⁺, Thomson's principle, Rayleigh monotonicity — bᵀL⁺b; the inverse on vectors summing to zero; current minimizes energy; lowering a resistance never raises R_eff.
  • hitting time, commute time, Foster's theorem — expected steps to reach a vertex; there and back, 2m R_eff; the edges' resistances sum to n − 1.
  • condition number, preconditioning, spectral sparsifier, stretch, low-stretch spanning tree — λ_n/λ₂; solving with a nearby easier matrix; a sparse H with L_H within 1 ± ε of L_G; an edge's tree-path resistance.
  • congestion, multiplicative weights, electrical flow, log barrier, interior-point method, min-ratio cycle — flow over capacity; raising the cost of overused edges; the flow current takes; −Σ log of the slack; Newton steps inside the polytope; the circulation with the best gain per length.
  • high-dimensional expander, link, local-to-global, spectral independence — a complex whose links all expand; the neighbourhood of a vertex as a graph; Garland's principle; a spectral condition for fast-mixing samplers.
  • small-set expansion hypothesis, unique games conjecture, sparsest cut — that small sets' expansion is hard to approximate; Khot's conjecture (Part 27); the cut of least edges per vertex on the smaller side.

Sources

  • D. Spielman, Spectral and Algebraic Graph Theory (book draft); F. Chung, Spectral Graph Theory (AMS, 1997); S. Hoory, N. Linial and A. Wigderson, "Expander graphs and their applications", Bull. AMS 2006; S. Vadhan, Pseudorandomness (2012); D. Levin, Y. Peres and E. Wilmer, Markov Chains and Mixing Times (2009); P. Doyle and J. L. Snell, Random Walks and Electric Networks (1984).
  • M. Fiedler, "Algebraic connectivity of graphs", Czech. Math. J. 1973, and "A property of eigenvectors of nonnegative symmetric matrices and its application to graph theory", Czech. Math. J. 1975; E. Fischer (1905) and R. Courant (1920) on the min-max principle.
  • J. Cheeger, "A lower bound for the smallest eigenvalue of the Laplacian" (1970); J. Dodziuk, "Difference equations, isoperimetric inequality and transience of certain random walks", Trans. AMS 1984; N. Alon and V. Milman, "λ₁, isoperimetric inequalities for graphs, and superconcentrators", J. Combin. Theory B 1985; N. Alon, "Eigenvalues and expanders", Combinatorica 1986; A. Sinclair and M. Jerrum, "Approximate counting, uniform generation and rapidly mixing Markov chains", Inform. and Comput. 1989.
  • J. Shi and J. Malik, "Normalized cuts and image segmentation", IEEE TPAMI 2000; A. Ng, M. Jordan and Y. Weiss, "On spectral clustering: analysis and an algorithm", NIPS 2001; G. Karypis and V. Kumar, "A fast and high quality multilevel scheme for partitioning irregular graphs", SIAM J. Sci. Comput. 1998.
  • S. Brin and L. Page, "The anatomy of a large-scale hypertextual web search engine", WWW 1998; T. Haveliwala and S. Kamvar, "The second eigenvalue of the Google matrix" (2003).
  • M. Pinsker, "On the complexity of a concentrator" (1973); G. Margulis, "Explicit constructions of concentrators" (1973); O. Gabber and Z. Galil, "Explicit constructions of linear-sized superconcentrators", JCSS 1981; A. Lubotzky, R. Phillips and P. Sarnak, "Ramanujan graphs", Combinatorica 1988; J. Friedman, "A proof of Alon's second eigenvalue conjecture and related problems", Mem. AMS 2008; A. Marcus, D. Spielman and N. Srivastava, "Interlacing families I: bipartite Ramanujan graphs of all degrees" and "Interlacing families II: mixed characteristic polynomials and the Kadison–Singer problem", Ann. of Math. 2015.
  • O. Reingold, S. Vadhan and A. Wigderson, "Entropy waves, the zig-zag graph product, and new constant-degree expanders and extractors", FOCS 2000 (Ann. of Math. 2002); O. Reingold, "Undirected ST-connectivity in log-space", STOC 2005; R. Aleliunas, R. Karp, R. Lipton, L. Lovász and C. Rackoff, "Random walks, universal traversal sequences, and the complexity of maze problems", FOCS 1979.
  • R. M. Tanner, "A recursive approach to low complexity codes", IEEE Trans. Inf. Theory 1981; M. Sipser and D. Spielman, "Expander codes", IEEE Trans. Inf. Theory 1996; D. Gillman, "A Chernoff bound for random walks on expander graphs", SIAM J. Comput. 1998; I. Dinur, "The PCP theorem by gap amplification", STOC 2006 (JACM 2007).
  • A. Singla, C.-Y. Hong, L. Popa and P. B. Godfrey, "Jellyfish: networking data centers randomly", NSDI 2012; A. Valadarsky, G. Shahaf, M. Dinitz and M. Schapira, "Xpander: towards optimal-performance datacenters", CoNEXT 2016.
  • A. Chandra, P. Raghavan, W. Ruzzo, R. Smolensky and P. Tiwari, "The electrical resistance of a graph captures its commute and cover times", STOC 1989; R. Foster, on the average impedance of an electrical network (1949); G. Pólya, on random walks in a street network, Math. Ann. 1921.
  • D. Spielman and S.-H. Teng, "Nearly-linear time algorithms for graph partitioning, graph sparsification, and solving linear systems", STOC 2004; D. Spielman and N. Srivastava, "Graph sparsification by effective resistances", STOC 2008; J. Batson, D. Spielman and N. Srivastava, "Twice-Ramanujan sparsifiers", STOC 2009.
  • J. Edmonds and R. Karp, "Theoretical improvements in algorithmic efficiency for network flow problems", JACM 1972; A. Goldberg and S. Rao, "Beyond the flow decomposition barrier", JACM 1998; P. Christiano, J. Kelner, A. Mądry, D. Spielman and S.-H. Teng, "Electrical flows, Laplacian systems, and faster approximation of maximum flow in undirected graphs", STOC 2011; L. Chen, R. Kyng, Y. Liu, R. Peng, M. Probst Gutenberg and S. Sachdeva, "Maximum flow and minimum-cost flow in almost-linear time", FOCS 2022.
  • H. Garland, "p-adic curvature and the cohomology of discrete subgroups of p-adic groups", Ann. of Math. 1973; A. Lubotzky, B. Samuels and U. Vishne on Ramanujan complexes (2005); N. Anari, K. Liu, S. Oveis Gharan and C. Vinzant, "Log-concave polynomials II: high-dimensional walks and an FPRAS for counting bases of a matroid", STOC 2019; N. Anari, K. Liu and S. Oveis Gharan, "Spectral independence in high-dimensional expanders and applications to the hardcore model", FOCS 2020; I. Dinur, S. Evra, R. Livne, A. Lubotzky and S. Mozes, "Locally testable codes with constant rate, distance, and locality", STOC 2022; P. Panteleev and G. Kalachev, "Asymptotically good quantum and locally testable classical LDPC codes", STOC 2022.
  • S. Arora, S. Rao and U. Vazirani, "Expander flows, geometric embeddings and graph partitioning", STOC 2004; P. Raghavendra and D. Steurer, "Graph expansion and the unique games conjecture", STOC 2010; S. Arora, B. Barak and D. Steurer, "Subexponential algorithms for unique games and related problems", FOCS 2010; S. Khot, D. Minzer and M. Safra, "Pseudorandom sets in Grassmann graph have near-perfect expansion", FOCS 2018.
About this partfrom its README

Part 56 of a sixty-one-part course in computer science (see the series plan and the syllabus), the first part of Act XI, The Research Frontier. A graph's matrices have eigenvalues, and they know what its drawing hides: how hard the graph is to cut, how fast a random walk on it forgets where it started, and how current flows through it. Graphs that are sparse yet impossible to cut, expanders, save random bits, correct errors and prove theorems, and the same linear algebra, through electrical flows and fast Laplacian solvers, led in 2022 to maximum flow in almost-linear time. Every bound is checked on small graphs and on the series' own: Part 18's city grid, Part 36's internet and a word graph from Pride and Prejudice.

The instruments are in explainer/cs/spectral/ (tested in tests/test_cs56_spectral.py):

  • spectra.py: the Laplacian L = D − A and the normalized Laplacian N = I − D^{−1/2} A D^{−1/2}; a stochastic block model with planted communities; conductance, and the sweep cut over the Fiedler order of N's second eigenvector (scaled by D^{−1/2}); Cheeger's inequality checked against conductance found by brute force over every cut of 12-vertex random graphs; the lazy walk (I + D^{−1}A)/2, its total-variation distance from stationarity step by step against the spectral-gap bound, on a cycle, a grid, a random 4-regular graph and a barbell; random simple d-regular graphs by stub pairing that avoids loops and repeated edges (after Steger and Wormald); the spectra of Part 18's city grid, Part 36's tiered internet and a word co-occurrence graph of one novel; random regular graphs against the Ramanujan bound 2√(d − 1), with the expander mixing lemma checked on random pairs of sets; rotation maps and the zig-zag product, with its second eigenvalue against the Reingold–Vadhan–Wigderson bound; effective resistance from the pseudo-inverse, and commute time 2m R_eff against simulated walks; a Spielman–Srivastava sparsifier (edges sampled by weight times resistance and reweighted); and conjugate gradients on an ill-conditioned Laplacian, plain and preconditioned by its sparsifier. (The scenes' small illustrative graphs, such as the Petersen graph, the circuits, the toy Tanner graph and the flow network, are computed inline with NumPy.)
Chapter notes
  • Hook. Two 16-vertex rings, every vertex with 3 neighbours, one with local chords and one with random chords: alike in a drawing, but λ₂ of the normalized Laplacian is 0.097 against 0.279. The same number for the series' own graphs: Part 18's city grid (256 vertices, 437 edges, λ₂ = 0.009, best sweep cut 0.038), Part 36's internet (125, 213, 0.191, 0.198) and the words of a novel (252, 1,346, 0.241, 0.333). The plan, ending at almost-linear max-flow.
  • 1. The Laplacian. L = D − A on a 5-vertex graph (the third vertex's row: 3, and −1 for each neighbour; L𝟏 = 0); xᵀLx = Σ (x_i − x_j)² derived as the energy in springs (a smooth labelling stores 7, the same values rearranged 39); zero energy means constant on components (two hexagons: eigenvalue 0 twice; one bridge: λ₂ = 0.20); λ₂ as Fiedler's algebraic connectivity (path 0.15, cycle 0.59, cube Q₃ 2.00, K₈ 8); two planted communities of 60 (120 vertices, 821 edges: λ₂ = 3.02 stands apart, the bulk starts at λ₃ = 4.60); the normalized Laplacian and the series' graphs again.
  • 2. Rayleigh quotients and the Fiedler vector. The Rayleigh quotient as a weighted average of eigenvalues; Courant–Fischer (Fischer 1905, Courant 1920), so adding an edge never lowers any λ_k; a cut as a ±1 vector (energy 4 per cut edge), the NP-hard minimum bisection and its relaxation, bisection ≥ nλ₂/4 (here 12/4 × 0.20 = 0.61 ≤ 1); the Fiedler vector drawn as colours, a slow wave on an 8 × 4 grid, Fiedler's 1975 connectivity theorem; on the 120-vertex graph its signs agree with the planted communities on 100% of the vertices; spectral clustering of three pentagon clusters by (v₂, v₃) (eigenvalues 0, 0.40, 0.40, then 2.08); Shi–Malik, Ng–Jordan–Weiss and METIS.
  • 3. Cheeger's inequality. Volume and conductance on a two-bridge graph (cutting off three vertices: 2 edges, volume 8, φ = 0.25; between the clusters: 2 edges, volume 18, φ = 0.11); λ₂/2 ≤ φ(G) ≤ √(2λ₂) (Cheeger 1970; Dodziuk 1984, Alon and Milman 1985); the easy side proved with one test vector; the hard side proved: shift by the weighted median, keep one half, cut at a random threshold on z², Cauchy–Schwarz; the sweep cut (best prefix of the toy: the first six; on the 120-vertex graph the curve dips to φ = 0.137 at k = 60, exactly the planted split); 53 connected random graphs on 12 vertices against brute force over 2,047 cuts: all inside the bounds, the sweep exact in 32 of 53; tightness (the hypercube, a long cycle).
  • 4. Random walks and mixing. p_{t+1} = p_t D^{−1}A spreading over the two-bridge graph; π = d/2m stationary; the 8-cycle oscillates, the lazy walk settles; D^{1/2}WD^{−1/2} = I − N/2, so μ₂ = 1 − γ/2 (0.936 on the toy, the slowest mode); TV ≤ ½√(1/π_min)(1 − γ/2)^t, so (2/γ − 1) ln 2 ≤ t_mix ≤ (1/γ) ln(4/π_min). Four 64-vertex graphs, measured: random 4-regular (gap 0.1654; bounds 8 and 33, t_mix 15), 8 × 8 grid (0.0463; 30 and 131; 51), cycle (0.0048; 288 and 1,151; > 300), barbell (993 edges, gap 0.0019; 730 and 2,920; > 300). PageRank revisited: the jump bounds |μ₂| by 0.85 (Haveliwala and Kamvar 2003); Part 18's 20,000 pages and 79,990 links converged to 10⁻¹² in 52 steps, about 0.58 a step.
  • 5. Expanders. Edge, vertex and spectral expansion on the Petersen graph (5 edges leave the outer 5; h = 1 over all 637 sets; eigenvalues 3, 1, −2, so λ = 2; Cheeger for degree d: 1 ≤ 1 ≤ 3.46); the expander mixing lemma (e(S, T) = 9 against d|S||T|/n = 7.2 on a random 3-regular graph) and its proof; Alon–Boppana by closed walks in the tree, and Ramanujan graphs (Lubotzky, Phillips and Sarnak 1988); one random d-regular graph on 400 vertices per degree: λ = 2.820, 3.434, 4.424, 5.244, 6.416 against 2√(d − 1) = 2.828, 3.464, 4.472, 5.292, 6.633 for d = 3, 4, 6, 8, 12, worst mixing-lemma error 0.20 to 0.34; existence by counting and a union bound (Pinsker 1973).
  • 6. Explicit expanders: the zig-zag product. Explicit means a neighbour function in time polynomial in log N; Margulis (1973) shear maps on a torus, Gabber–Galil (1981), Lubotzky–Phillips–Sarnak; the product drawn as a step, a cloud move and a step (G = K₅, H a 4-cycle: 20 vertices of degree 4); why the gap survives, 1 − λ_Z ≥ (1 − λ_H)²(1 − λ_G) (after Vadhan); our product (G random 8-regular on 60, H random 3-regular on 8: 480 vertices of degree 9) measures λ_Z = 0.811 against λ_G = 0.665, λ_H = 0.745, the RVW bound 0.908, the proved bound 0.978 and λ_G + λ_H + λ_H² = 1.966; the recursion G_{t+1} = G_t² ⓩ H keeping λ ≤ 2/5; Reingold's SL = L (2005).
  • 7. Expanders at work. A walk instead of fresh coins: r + t log₂ D bits; the hitting bound μ(μ + λ)^t (and Gillman's Chernoff bound); illustrative savings with r = 256, μ = ½, λ = ¼, degree 2¹⁰: error 2⁻²⁰ for 716 bits (46 steps) against 5,120; expander codes (Tanner 1981; Sipser and Spielman 1996): unique neighbours on a toy code of 12 bits and 9 checks (2 bits, 6 edges, 4 unique checks, 1 shared); flip decoding of 2 errors (4 unsatisfied checks, then 3, then 0); Dinur's gap amplification (Part 27); Jellyfish (2012) and Xpander (2016).
  • 8. Graphs as electrical networks. Ohm and Kirchhoff give Lx = b; one amp through nine one-ohm resistors (voltages 1.36 down to 0, 0.45 in = 0.09 + 0.36 out at one vertex); R_eff = bᵀL⁺b (series 2, parallel 0.5, our circuit 1.36); Thomson's principle (electrical 1.36, two paths 1.50, one path 3.00) and Rayleigh monotonicity; commute time = 2m R_eff derived (Chandra et al. 1989); a 5 × 5 grid corner to corner: m = 40, R_eff = 2.136, predicted 170.9, measured 174.0 over 2,000 round trips (1.8% apart); Pólya's walks by shorting shells (8k + 4 edges).
  • 9. Laplacian solvers and sparsifiers. CG sees one hop further per iteration (a 20-vertex path: κ = 161, exact in 10 steps); preconditioning by a spectral sparsifier: 300 vertices, 13,657 edges, κ = 40.2, a sparsifier of 1,591 edges with xᵀL_Hx/xᵀL_Gx in [0.965, 1.033] on 200 random x, CG 67 iterations against 14; Foster's theorem (two K₈ and a bridge: bridge 1.00, clique edges 0.25, 57 edges summing to 15 = n − 1); Spielman–Srivastava sampling (40 draws keep 27 of 57 edges, the bridge among them; missing it: 6% by resistance, 49% uniformly), Batson–Spielman– Srivastava; all resistances by Johnson–Lindenstrauss; low-stretch trees on a 6 × 6 grid (snake: total stretch 210, κ = 46.8; spine: 150, κ = 23.2); Spielman–Teng (2004).
  • 10. From electrical flows to max-flow. An 8-vertex network with capacities 1 to 4 and maximum flow 4; the electrical flow with r_e = 1/u_e² puts 2.82 on an edge of capacity 2 (congestion 1.41); Thomson's lemma bounds the weighted mean of squared congestion by 1 (0.43 here); multiplicative weights over electrical flows (ε = 0.5, 30 rounds): the averaged flow's worst congestion falls from 1.412 to 1.035, so scaling gives 3.86, 96.6% of the maximum (Christiano, Kelner, Mądry, Spielman and Teng 2011); interior points, where every Newton step is an electrical flow; min-ratio cycles on low-stretch trees (Chen, Kyng, Liu, Peng, Probst Gutenberg and Sachdeva 2022); the exponent of m from 3 (1972) to 1.5 (1998), 4/3 (2011) and 1 + o(1) (2022).
  • 11. Frontier: high-dimensional expanders. Complexes, links and Garland's local-to-global principle; Ramanujan complexes; what they have done (matroid bases sampled by Anari, Liu, Oveis Gharan and Vinzant 2019, spectral independence, the 2022 locally testable codes and good quantum LDPC codes, Dinur's PCP proof); the random regular graphs under 2√(d − 1), Friedman's theorem and Marcus–Spielman–Srivastava's bipartite Ramanujan graphs of every degree. Four open problems and the ★ research problem, the small-set expansion hypothesis.
  • Outro. Recap, payoffs (Parts 57, 58, 59, 60, 61), practice, problems, next part.

Companion material in this repository

The syllabus's plan for this partfrom SYLLABUS.md, the plan of record
  1. The Laplacian L = D − A; quadratic forms xᵀLx as energy; λ₂ and connectivity.
  2. The Courant–Fischer theorem; Rayleigh quotients; why the second eigenvector partitions a graph (spectral clustering, Fiedler 1973).
  3. Cheeger's inequality, both directions, proved on screen; the sweep cut.
  4. Random walks: stationary distributions, mixing time from the spectral gap; the lazy walk; PageRank revisited (Part 18).
  5. Expanders: definitions (edge, vertex, spectral); the expander mixing lemma; Ramanujan graphs and the Alon–Boppana bound; existence by the probabilistic method (Part 2).
  6. Explicit constructions: Margulis–Gabber–Galil; the zig-zag product (Reingold, Vadhan & Wigderson 2000); Reingold's SL = L (2005).
  7. Expanders at work: expander codes (Sipser & Spielman), randomness-efficient sampling, the PCP theorem's gap amplification (Dinur 2006, callback to Part 27).
  8. Electrical networks: effective resistance, the Laplacian as a circuit (Part 3's physics), commute times.
  9. Laplacian solvers: spectral sparsification (Spielman & Srivastava), the Spielman–Teng near-linear solver (2004), preconditioning with low-stretch trees.
  10. Electrical flows to max-flow: Christiano et al. (2011), interior-point methods; Chen, Kyng, Liu, Peng, Probst Gutenberg & Sachdeva (2022), almost-linear max-flow (verify).
  11. Frontier: high-dimensional expanders; spectral independence and the resolution of sampling conjectures; open problems.
  12. Outro.

Computed: spectra of the series' graphs (the novels' word co-occurrence graph, the city grid of Part 18, the internet of Part 36); a spectral partition against the true communities; mixing times measured against the spectral-gap bound; Cheeger's inequality checked on random graphs; a zig-zag expander built and its λ₂ measured; a Laplacian solved by CG with and without a sparsifier. Visuals: eigenvectors drawn as vertex colours; the sweep cut moving through the Fiedler order; a random walk's distribution flattening; the zig-zag product as a step, a cloud move, a step. In practice: spectral clustering, graph partitioning for sharding (METIS), graph neural networks' spectral roots, expander-based network topologies (Jellyfish, Xpander). Reading: Spielman, Spectral and Algebraic Graph Theory; Hoory, Linial & Wigderson 2006 (survey); Chung, Spectral Graph Theory; Vadhan, Pseudorandomness; Reingold, Vadhan & Wigderson 2000; Reingold 2005; Spielman & Teng 2004; Chen et al. 2022.

中文讲义

本讲的中文部分(与英文版对应)。

习题与解答
  1. 能量。 证明 xᵀLx = Σ_{(i,j)∈E} (x_i − x_j)²,并证明特征值 0 的重数等于连通分量的个数。

    解答

    由 L = D − A,xᵀDx = Σ_i d_i x_i² = Σ_{(i,j)∈E} (x_i² + x_j²),因为每条边给它的两个端点的度各加一; xᵀAx = Σ_{i,j} A_ij x_i x_j = 2 Σ_{(i,j)∈E} x_i x_j,因为每条边在 A 中以 (i, j) 和 (j, i) 各出现一次。相减得 xᵀLx = Σ_E (x_i² + x_j² − 2x_i x_j) = Σ_E (x_i − x_j)² ≥ 0。所以 L 对称半正定,于是 xᵀLx = ‖L^{1/2}x‖² 恰在 Lx = 0 时为零。因此 L 的零空间是 {x:每条边两端取值相等},即在每个连通分量上取常数的向量(分量内的一条路径迫使沿途取值 相等)。若连通分量为 C₁, …, C_k,它们的指示向量支撑集互不相交,因而线性无关,并张成这个空间:维数为 k。L 对称,所以 0 的代数重数等于其特征空间的维数 k。第 1 章的两个六边形有两个特征值 0;加一座桥后只剩一个,另一个升到 λ₂ = 0.20。

  2. 两个谱。 计算圈 C_n 与超立方体 Q_d 的拉普拉斯谱。

    解答

    圈:把顶点按模 n 编号,则 L = 2I − S − S⁻¹,S 为循环移位。向量 χ_k(j) = ω^{jk}(ω = e^{2πi/n}, k = 0, …, n − 1)满足 Sχ_k = ω^k χ_k,所以 Lχ_k = (2 − ω^k − ω^{−k})χ_k = (2 − 2cos(2πk/n))χ_k。这 n 个向量两两正交, 所以这就是全部的谱:2 − 2cos(2πk/n),k = 0, …, n − 1,实特征向量为 cos(2πjk/n) 与 sin(2πjk/n);除 0(n 为偶数时还有 4)以外每个特征值出现两次。特别地 λ₂ = 2 − 2cos(2π/n) ≈ 4π²/n²;n = 8 时为 2 − √2 ≈ 0.586,即第 1 章的圈(测试检查了 n = 12)。超立方体:顶点为 x ∈ {0, 1}^d,恰差一位的两点相连。对 S ⊆ {1, …, d} 令 χ_S(x) = (−1)^{Σ_{i∈S} x_i}。翻转第 i 位 时,若 i ∈ S 则 χ_S 乘以 −1,否则不变,所以 (Aχ_S)(x) = Σ_i χ_S(x ⊕ e_i) = (d − 2|S|)χ_S(x),Lχ_S = 2|S| χ_S。这 2^d 个向量两两正交,所以谱为 2k,重数 C(d, k),k = 0, …, d:Q₃ 为 0, 2, 2, 2, 4, 4, 4, 6,λ₂ = 2,与第 1 章一致。这两个图 也说明了第 3 章关于紧性的话。Q_d 是 d-正则的,所以 N 的 λ₂ 为 2/d;半立方体 {x₁ = 0} 割断 2^{d−1} 条边,体积为 d · 2^{d−1},所以 φ ≤ 1/d = λ₂/2,再由 Cheeger 下界得 φ(Q_d) = λ₂/2,恰好取等。n 为偶数时,C_n 的 λ₂(N) = 1 − cos(2π/n) ≈ 2π²/n²,而 φ = 2/n(每个割至少割断两条边,较小一侧的体积至多为 n):与 √λ₂ 同阶。n = 64 时 λ₂(N) = 0.0048(第 4 章的谱间隙),φ = 0.031,√(2λ₂) = 0.098。

  3. Cheeger 不等式的容易一侧。 证明 λ₂/2 ≤ φ(G)。

    解答

    N = D^{−1/2}LD^{−1/2} 有特征值 0,特征向量为 D^{1/2}𝟏,所以由 Courant–Fischer 定理,λ₂(N) 是 xᵀNx/xᵀx 在所有 与 D^{1/2}𝟏 正交的非零 x 上的最小值。代入 x = D^{1/2}y:约束变为 Σ_i d_i y_i = 0,分子为 yᵀLy = Σ_E (y_i − y_j)²,分母为 Σ_i d_i y_i²。所以任何这样的 y 都给出 λ₂ 的一个上界。对集合 S,令 y 在 S 上为 a、在 S 外为 −b,其中 a = 1/vol S, b = 1/vol S̄;则 Σ_i d_i y_i = 1 − 1 = 0。只有被割断的边两端有差,每条差 a + b,所以分子为 |E(S, S̄)|(a + b)²,分母为 vol S · a² + vol S̄ · b² = a + b。于是 λ₂ ≤ |E(S, S̄)|(a + b) ≤ 2|E(S, S̄)|/min(vol S, vol S̄) = 2φ(S),因为 a 与 b 都不超过较小体积的倒数。这对每个 S 都成立,对最好的那个也成立:λ₂/2 ≤ φ(G)。在第 3 章的双桥图上,λ₂ = 0.129,穷举全部 2,047 个割得 φ(G) = 1/9 ≈ 0.111:0.064 ≤ 0.111 ≤ √(2 × 0.129) = 0.508。

  4. 扩展图混合引理。 证明 |e(S, T) − d|S||T|/n| ≤ λ√(|S||T|)。

    解答

    设 A 为 n 个顶点的 d-正则图的邻接矩阵,特征值 d = μ₁ ≥ μ₂ ≥ … ≥ μ_n,标准正交特征向量 v₁ = 𝟏/√n, v₂, …, v_n, λ = max_{i≥2} |μ_i|。计数 e(S, T) = 𝟏_Sᵀ A 𝟏_T 是满足 s ∈ S、t ∈ T 且相连的有序对 (s, t) 的个数。写 𝟏_S = (|S|/n)𝟏 + x,𝟏_T = (|T|/n)𝟏 + y,其中 x, y ⊥ 𝟏,然后展开。主项为 (|S||T|/n²) 𝟏ᵀA𝟏 = d|S||T|/n,因为 𝟏ᵀA𝟏 = dn。交叉项为零:A𝟏 = d𝟏,所以 (|S|/n) 𝟏ᵀAy = (|S|/n) d 𝟏ᵀy = 0,同理 xᵀA𝟏 = 0。于是 e(S, T) − d|S||T|/n = xᵀAy。写 y = Σ_{i≥2} c_i v_i,则 Ay = Σ_{i≥2} μ_i c_i v_i,‖Ay‖ ≤ λ‖y‖,由 Cauchy–Schwarz 得 |xᵀAy| ≤ λ‖x‖‖y‖。最后 ‖x‖² = ‖𝟏_S‖² − |S|²/n = |S|(1 − |S|/n) ≤ |S|,y 同理,引理得证(保留这些因子,还得到更强的 λ√(|S|(1 − |S|/n)|T|(1 − |T|/n)))。第 5 章 20 个顶点的例子中 e(S, T) = 9,对比 7.2;在 400 个顶点的随机正则图上,200 对随机集合中归一化误差的最大值在 0.20 到 0.34 之间,而 λ 在 2.82 到 6.42 之间。

  5. 动手。 用你选的两个图构造 zig-zag 积(之字形积),并把它的第二特征值与 RVW 界比较。

    解答

    解答要点。 explainer/cs/spectral/spectra.py 里已有所需的部件。H 的顶点数必须等于 G 的度 D:取 G = random_regular(N, D, seed),H = random_regular(D, d, seed)、cycle(D) 或 D 个顶点的完全图。 rotation_map_regular 给每个顶点的邻居编号,并对从 v 到它第 i 个邻居 w 的边记下 v 是 w 的第几个邻居;zigzag(G, H) 对 每个顶点 (v, a) 和每一对 (i, j) 加一条边,它由三步组成:zig(在 H 中从 a 走到它的第 i 个邻居 a′)、大步(从 v 的端口 a′ 走到 w 的端口 b′)、zag(在 H 中从 b′ 走到它的第 j 个邻居 b)。检查 Z 对称且是 d²-正则的(如 test_zigzag_regular 所做),然后把每个 λ 算作绝对值第二大的特征值(np.linalg.eigvalsh)除以度,把 λ_Z 与 RVW 界 f(λ_G, λ_H) = ½(1 − λ_H²)λ_G + ½√((1 − λ_H²)²λ_G² + 4λ_H²)、第 6 章证明的界 1 − (1 − λ_H)²(1 − λ_G) 以及 λ_G + λ_H + λ_H² 比较。zigzag_experiment(G 为 60 个顶点的随机 8-正则图,H 为 8 个顶点的随机 3-正则图)给出 480 个 度为 9 的顶点,λ_Z = 0.811,对比 0.908、0.978 和 1.966。用同一个 G 和 H = K₈(λ_H = 1/7),积的度为 49,λ_Z = 0.681, 在打印的位数内等于 RVW 界;用 60 个顶点的随机 5-正则图 G 和 H = C₅,λ_Z = 0.932,对比 0.957。两个陷阱:二部图 H(例如测试 中的 4-圈)的 λ_H = 1,所有界都是 1,而 λ_Z 也确实是 1;Z 可能有重边和自环,必须按重数保留(代码对每个 (i, j) 加一)。 完整的答案还应迭代 G_{t+1} = G_t² ⓩ H,看度保持为 d²,同时 λ 保持有界。

  6. ★ 研究。 小集合扩张假设。

    讨论。 尚未解决。Raghavendra 和 Steurer(2010)猜想:对每个 η > 0 都存在 δ > 0,使得区分下面两种正则图是 NP 难的: 一种有某个占体积 δ 比例的集合,其导率至多为 η;另一种中每个这样的集合导率都至少为 1 − η。他们还证明了这个假设蕴含唯一 博弈猜想。谱方法无法直接解决它:Cheeger 不等式保证某个割很便宜,却不说它的两侧有多大;一个图可以有许多接近零的特征值, 而它所有的小集合都扩张,所以谱的底部看不出不扩张的小集合。证据指向两边。Arora、Barak 和 Steurer(2010)用利用小特征值 很少的图的方法,在亚指数时间(exp 的指数是 n 的一个随 η 缩小的幂)内求解小集合扩张和唯一博弈;因此,如果 3-SAT 需要指数 时间,任何证明这个假设的归约都必须把实例规模放大到一个随 η 缩小而增长的幂。另一方面,2-to-2 定理(Khot、Minzer 和 Safra 2018,与 Dinur 和 Kindler 合作)来自证明 Grassmann 图中不 扩张的小集合具有刚性的结构。好的部分结果可以是:在小特征值很少的图之外的一类自然的图上,用多项式时间求解小集合扩张;证明 平方和(sum-of-squares)这类层级的某个固定层在某一族小集合扩张实例上失效;或者给出从小集合扩张到某个尚不知与之等价的问题 的归约。

Build the film

python -m videos.cs.cs56.compute        # the part's numbers, into .cache/cs56
python tools/build.py cs56                  # render and assemble the film
EXPLAINER_TTS=silent python tools/qa_scene.py cs56 Hook   # one chapter, silent, with a contact sheet

Scenes: videos/cs/cs56. Setup: see the course page. Source of these notes: the README and the scenes' narration.

Build it
python -m videos.cs.cs56.compute
python -m unittest tests.test_cs56_spectral
python tools/build.py cs56