Tutorials › Graph Theory (Undergraduate) › Rayleigh Quotients and the Spectral Gap

Expanders and Random Walks on Graphs · Tutorial 664 of 799

Rayleigh Quotients and the Spectral Gap

Learn how the second-largest eigenvalue of a regular graph’s random-walk matrix is characterized by the least Dirichlet energy per unit squared norm among nonzero mean-zero functions.

Advanced 9 min read

What You'll Learn

  • Define the random-walk matrix and spectral gap for a connected regular graph.
  • Derive the Dirichlet energy formula from the matrix expression.
  • Prove the variational characterization using an orthonormal eigenbasis.
  • Compute spectral gaps and Rayleigh quotients for three small regular graphs.
  • Distinguish the spectral gap from an absolute-eigenvalue gap.
  • Identify and correct a common normalization error in the energy formula.

From a Random Walk to a Rayleigh Quotient

For a random walk on a regular graph, the transition matrix is a rescaled adjacency matrix. Its eigenvalues describe how the walk acts on functions on the vertices. The spectral gap measures how far the second-largest eigenvalue lies below \(1\). This tutorial derives a variational formula for that gap and expresses its numerator as an energy built from differences across edges.

Throughout, \(G=(V,E)\) is a finite, simple, undirected, connected \(d\)-regular graph, where \(d\ge 1\). Write \(n=|V|\). For a function \(f:V\to\mathbb R\), define its uniform mean by \(\overline f=\frac1n\sum_{v\in V}f(v)\). We use the inner product and norm

$$ \langle f,g\rangle_\pi=\frac1n\sum_{v\in V}f(v)g(v), \qquad \|f\|_\pi^2=\langle f,f\rangle_\pi. $$

The subscript \(\pi\) indicates the uniform probability distribution on the vertices. In a regular graph this distribution is stationary for the simple random walk: from each vertex the walk chooses each of its \(d\) neighbors with probability \(1/d\).

Definition: The random-walk matrix \(P\) is given by \(P_{uv}=1/d\) when \(uv\in E\), and \(P_{uv}=0\) otherwise. It acts on a function by \((Pf)(v)=\frac1d\sum_{u\in N(v)}f(u)\). Since \(G\) is undirected and regular, \(P\) is a real symmetric matrix. Its eigenvalues are ordered \(1=\lambda_1\ge\lambda_2\ge\cdots\ge\lambda_n\). The spectral gap in this tutorial means \(\gamma=1-\lambda_2\).

Connectedness ensures that the eigenvalue \(1\) occurs only on constant functions. The spectral theorem for real symmetric matrices gives an orthonormal basis of eigenvectors; applying it to \(P\), we can take the constant functions as the eigenspace for \(\lambda_1=1\). We justify the connectedness claim as part of the energy identity below. The definition here uses the second-largest eigenvalue, not the largest absolute value among the nonconstant eigenvalues. That distinction matters for graphs with eigenvalues near \(-1\).

The Dirichlet Energy

Definition: The Dirichlet energy of a function \(f:V\to\mathbb R\) is \(\mathcal E(f,f)=\langle f,(I-P)f\rangle_\pi\). It measures, in aggregate, how much \(f\) changes across adjacent vertices.

The matrix definition has a direct edge-by-edge form. Each edge is counted once in the sum below.

Proposition: For every function \(f:V\to\mathbb R\) on a \(d\)-regular graph,
$$ \mathcal E(f,f)=\frac{1}{nd}\sum_{uv\in E}(f(u)-f(v))^2. $$

Proof. By the definition of \(P\),

$$ \langle f,(I-P)f\rangle_\pi =\frac1n\sum_{v\in V}f(v)^2 -\frac{1}{nd}\sum_{v\in V}\sum_{u\in N(v)}f(v)f(u). $$

In the double sum, every undirected edge \(uv\) contributes once as the ordered pair \((u,v)\) and once as \((v,u)\). Thus the double sum is \(2\sum_{uv\in E}f(u)f(v)\). Also, regularity gives \(\sum_{uv\in E}(f(u)^2+f(v)^2)=d\sum_{v\in V}f(v)^2\), since each vertex appears in exactly \(d\) edges. Expanding the squares on the right-hand side of the claimed identity therefore gives

$$ \frac{1}{nd}\sum_{uv\in E}(f(u)-f(v))^2 =\frac1n\sum_{v\in V}f(v)^2 -\frac{2}{nd}\sum_{uv\in E}f(u)f(v) =\langle f,(I-P)f\rangle_\pi. $$

This proves the identity. If the energy is zero, every squared difference across an edge is zero, so \(f\) takes equal values at the endpoints of every edge. Along any path its value remains constant; connectedness then makes \(f\) constant on all of \(V\). Conversely, a constant function has zero difference on every edge and hence zero energy. In particular, the only functions satisfying \(Pf=f\) are constants, so the eigenvalue \(1\) is simple. \(\square\)

The factor \(1/(nd)\) depends on using the normalized inner product \(\langle\cdot,\cdot\rangle_\pi\), and on summing over undirected edges just once. Keeping these conventions fixed makes the variational quotient easy to interpret and compute.

Variational Characterization of the Gap

Theorem: For a finite, connected, \(d\)-regular graph with \(d\ge1\), the spectral gap \(\gamma=1-\lambda_2\) satisfies
$$ \gamma =\min_{\substack{f:V\to\mathbb R,\ f\ne 0\\ \overline f=0}} \frac{\mathcal E(f,f)}{\|f\|_\pi^2} =\min_{\substack{f:V\to\mathbb R,\ f\ne 0\\ \sum_{v\in V}f(v)=0}} \frac{\displaystyle\frac{1}{nd}\sum_{uv\in E}(f(u)-f(v))^2} {\displaystyle\frac1n\sum_{v\in V}f(v)^2}. $$

Proof. Let \(q_1,\ldots,q_n\) be an orthonormal eigenbasis for \(P\) in the uniform inner product, with \(Pq_i=\lambda_iq_i\) and \(q_1\) constant. A function has mean zero exactly when it is orthogonal to \(q_1\): the inner product with a nonzero constant function is a nonzero constant multiple of its mean. Thus every nonzero mean-zero \(f\) has an expansion \(f=\sum_{i=2}^n c_iq_i\), with at least one \(c_i\ne0\). Orthonormality gives \(\|f\|_\pi^2=\sum_{i=2}^n c_i^2\). Using the eigenvector equations gives \(\mathcal E(f,f)=\sum_{i=2}^n(1-\lambda_i)c_i^2\). Since \(\lambda_i\le\lambda_2\) for every \(i\ge2\), each coefficient \(1-\lambda_i\) is at least \(1-\lambda_2\). Therefore

$$ \frac{\mathcal E(f,f)}{\|f\|_\pi^2} =\frac{\sum_{i=2}^n(1-\lambda_i)c_i^2}{\sum_{i=2}^n c_i^2} \ge 1-\lambda_2. $$

For equality, choose a nonzero eigenvector \(q_2\) for \(\lambda_2\). It is orthogonal to the constant eigenvector, so it has mean zero, and its quotient is \((1-\lambda_2)\|q_2\|_\pi^2/\|q_2\|_\pi^2=1-\lambda_2\). Hence the minimum is attained and equals the gap. Substituting the edge formula for \(\mathcal E(f,f)\) proves the final expression. \(\square\)

The minimization is restricted to mean-zero functions because constants have zero energy and would make an unrestricted minimum equal to zero. The quotient compares edge variation with squared size: functions that change little across edges relative to their norm give a small quotient.

Worked Examples

Worked Example: The Four-Cycle

Let \(G\) have \(V=\{1,2,3,4\}\) and \(E=\{12,23,34,41\}\). This graph is connected and \(2\)-regular. Consider \(f=(1,0,-1,0)\), meaning \(f(1)=1\), \(f(2)=0\), \(f(3)=-1\), and \(f(4)=0\). Its mean is \((1+0-1+0)/4=0\), and its squared norm is \((1^2+0^2+(-1)^2+0^2)/4=2/4=1/2\).

The four edge differences, in the listed edge order, are \(1-0=1\), \(0-(-1)=1\), \(-1-0=-1\), and \(0-1=-1\). Their squares sum to \(1+1+1+1=4\). The energy is \(4/(4\cdot2)=1/2\), so this function’s quotient is \((1/2)/(1/2)=1\).

To verify that this is the minimum, apply \(P\), which averages the two neighboring values at each vertex. For the constant vector \((1,1,1,1)\), this gives the same vector. For \((1,0,-1,0)\), the neighbor averages are \((0,0,0,0)\). For \((0,1,0,-1)\), they are also \((0,0,0,0)\). For \((1,-1,1,-1)\), they are \((-1,1,-1,1)\), which is the negative of that vector. These four linearly independent vectors form a basis, so the eigenvalues are \(1,0,0,-1\). Thus \(\lambda_2=0\), and the gap \(1-0=1\) agrees with the computed quotient.

Worked Example: The Complete Graph on Three Vertices

Let \(G\) have \(V=\{1,2,3\}\) and \(E=\{12,13,23\}\). Each vertex has two neighbors, so \(d=2\). Take \(f=(1,-1,0)\). Its mean is \((1-1+0)/3=0\), and its squared norm is \((1^2+(-1)^2+0^2)/3=2/3\).

The edge differences are \(f(1)-f(2)=2\), \(f(1)-f(3)=1\), and \(f(2)-f(3)=-1\); their squared sum is \(4+1+1=6\). Therefore \(\mathcal E(f,f)=6/(3\cdot2)=1\), and the quotient is \(1/(2/3)=3/2\).

For any mean-zero function \(g\) on these three vertices, \(g(1)+g(2)+g(3)=0\). At vertex \(v\), the sum of the values at the other two vertices is therefore \(-g(v)\). Since \(P\) averages those two values, \(Pg=-g/2\). Every mean-zero function is consequently an eigenvector with eigenvalue \(-1/2\); constants have eigenvalue \(1\). Hence \(\lambda_2=-1/2\), and the gap is \(1-(-1/2)=3/2\), matching the quotient.

Worked Example: The Two-Vertex Graph

Let \(G\) have \(V=\{a,b\}\) and \(E=\{ab\}\). It is connected and \(1\)-regular. For \(f(a)=1\) and \(f(b)=-1\), the mean is \((1-1)/2=0\), and the squared norm is \((1^2+(-1)^2)/2=1\). The single edge has difference \(1-(-1)=2\), so its squared difference is \(4\). The energy is \(4/(2\cdot1)=2\), giving quotient \(2/1=2\).

The random walk sends the value at each vertex to the value at the other vertex. Thus constants have eigenvalue \(1\), while \(f\) has eigenvalue \(-1\), and \(\lambda_2=-1\). The gap is \(1-(-1)=2\), as the quotient predicts. This example also shows why this tutorial defines the gap as \(1-\lambda_2\): it is not \(1-|\lambda_2|\), which would be zero here.

Interpretation and a Common Pitfall

By the theorem, a small spectral gap means there is a nonzero mean-zero function whose squared differences across edges are small compared with its squared norm. The mean-zero condition removes the constant functions, which have no variation at all. This gives a useful way to read the gap: it is the least edge-based variation available to a function of unit squared norm after constants have been excluded. It also gives a concrete optimization problem for finding the gap, rather than only an eigenvalue calculation.

Common mistake: omitting the normalization factor. In the four-cycle example, the sum of the squared edge differences for \(f=(1,0,-1,0)\) is \(4\). Dividing only by \(d=2\) would give \(4/2=2\) for the energy. That is incorrect for the normalized inner product used here: the edge formula divides by \(nd=4\cdot2=8\), so the energy is \(4/8=1/2\). The squared norm is also normalized by \(n\), giving \(2/4=1/2\); the quotient is therefore \(1\), not \(2/(1/2)=4\). Always check that the energy and norm use the same inner-product convention.

Another distinction is that the variational formula selects the second-largest eigenvalue, not the eigenvalue with second-largest absolute value. For a non-lazy walk, negative eigenvalues can have large absolute value, as the two-vertex example shows. Replacing \(\lambda_2\) by an absolute-value convention changes the parameter being studied and does not give the minimum quotient proved here.

Check Your Understanding

Use the definitions and variational formula to answer the following questions.

  1. Why must the minimization exclude constant functions?
  2. For a connected regular graph, what does zero Dirichlet energy imply about a function, and where is connectedness used?
  3. Explain why an eigenvector for \(\lambda_2\) attains the minimum in the variational characterization.
  4. For the four-cycle example, verify the mean and squared norm of \(f=(0,1,0,-1)\), then compute its edge-energy quotient.
  5. What is the difference between the gap \(1-\lambda_2\) and a quantity defined using the absolute values of nonconstant eigenvalues?