The Courant-Fischer Theorem and Power Iteration
Eigenvalues are defined by an equation, , but almost every proof in spectral graph theory uses a different description: as the optimum of an optimization problem over vectors. That view, the Courant-Fischer theorem, turns any well-chosen test vector into a bound on an eigenvalue, and it is also the basis of the simplest algorithm for computing the eigenvectors we need, power iteration.
The Rayleigh quotient
For a symmetric and , the Rayleigh quotient is . By the spectral theorem (Symmetric Diagonalization) has an orthonormal eigenbasis with eigenvalues . Writing ,
a weighted average of the eigenvalues with weights . So , with equality at and . If then and ; this is already the statement we use most.
The theorem
Theorem (Courant-Fischer; Fischer 1905, Courant 1920). For symmetric with eigenvalues and every ,
Proof of the first equality. Taking , every is an average of , so the max over is ; hence the min is at most . Conversely, any -dimensional meets the -dimensional in a nonzero vector (the dimensions add up to more than ), and that vector has . So every has max at least . The second equality follows by applying the first to .
For a Laplacian, , so the case reads
Test vectors give bounds
Upper bounds on . Any gives . For the path try the linear vector : every edge contributes 1, so the numerator is , and . Hence , within a factor of the truth . A clever test vector is often all a proof needs.
Lower bounds on . Any gives ; with for an edge one gets , so for unweighted graphs (take : ).
Monotonicity. If is plus edges (or with larger weights), then for all , written (the Loewner order). Courant-Fischer then gives for every , not only the extremes. Adding edges can only make a graph better connected, spectrally.
import numpy as np
def laplacian(n, edges):
L = np.zeros((n, n))
for u, v in edges:
L[u, u] += 1; L[v, v] += 1; L[u, v] -= 1; L[v, u] -= 1
return L
for n in [5, 20, 100]:
L = laplacian(n, [(i, i + 1) for i in range(n - 1)])
x = np.arange(n) - (n - 1) / 2 # linear test vector, orthogonal to 1
print(f"P_{n:<3}: lambda_2 = {float(np.linalg.eigvalsh(L)[1]):.6f} R(x) = {float(x @ L @ x / (x @ x)):.6f}"
f" 12/(n(n+1)) = {12 / (n * (n + 1)):.6f}")
# monotonicity: add edges to a 6-cycle one at a time; every eigenvalue can only go up
n = 6
edges = [(i, (i + 1) % n) for i in range(n)]
print("C_6 ", np.round(np.linalg.eigvalsh(laplacian(n, edges)), 4) + 0.0)
for extra in [(0, 3), (1, 4), (2, 5)]:
edges.append(extra)
print(f"+ edge {extra}", np.round(np.linalg.eigvalsh(laplacian(n, edges)), 4) + 0.0)P_5 : lambda_2 = 0.381966 R(x) = 0.400000 12/(n(n+1)) = 0.400000
P_20 : lambda_2 = 0.024623 R(x) = 0.028571 12/(n(n+1)) = 0.028571
P_100: lambda_2 = 0.000987 R(x) = 0.001188 12/(n(n+1)) = 0.001188
C_6 [0. 1. 1. 3. 3. 4.]
+ edge (0, 3) [0. 1. 2. 3. 3. 5.]
+ edge (1, 4) [0. 1.4384 3. 3. 3. 5.5616]
+ edge (2, 5) [0. 3. 3. 3. 3. 6.]
Every column of the second table is nondecreasing. The last graph, the cycle with its three long diagonals, is the complete bipartite graph , with spectrum .
Power iteration
To compute the eigenvector of the largest eigenvalue of a positive semidefinite matrix , start from a random and repeat . In the eigenbasis, , and the top term dominates at a rate . The Rayleigh quotient converges even faster, at rate .
For the Fiedler vector we need the second smallest eigenvalue of . Flip the spectrum with for some (say ), whose largest eigenvalue belongs to , and deflate: subtract the mean from after every step so that it stays orthogonal to . Then the iteration converges to the eigenvector of , which is the Fiedler vector, at rate per step.
fiedler_power(L, c, iterations)
1 x ← random vector; x ← x − mean(x)·1; x ← x / ‖x‖
2 repeat iterations times
3 y ← c·x − L x (one matrix-vector product: O(m) time)
4 y ← y − mean(y)·1 (deflate the eigenvector 1)
5 x ← y / ‖y‖
6 return x, xᵀ L x (vector and its Rayleigh quotient)Each step costs one multiplication by , time for a sparse graph. The catch is the rate: when and are close relative to , convergence is slow. Production codes use the Lanczos method (or LOBPCG), which builds a Krylov subspace from the same matrix-vector products and needs roughly the square root of the number of iterations; scipy.sparse.linalg.eigsh calls ARPACK's implicitly restarted Lanczos.
import numpy as np
def laplacian(n, edges):
L = np.zeros((n, n))
for u, v in edges:
L[u, u] += 1; L[v, v] += 1; L[u, v] -= 1; L[v, u] -= 1
return L
def fiedler_power(L, iterations, seed=0):
c = 2 * L.diagonal().max() # c >= lambda_n
x = np.random.default_rng(seed).standard_normal(len(L))
for _ in range(iterations):
x = c * x - L @ x
x -= x.mean() # stay orthogonal to the all-ones vector
x /= np.linalg.norm(x)
return x, float(x @ L @ x)
# two 5-cliques joined by a path of length 3
edges = [(a + s, b + s) for s in (0, 7) for a in range(5) for b in range(a + 1, 5)] + [(4, 5), (5, 6), (6, 7)]
L = laplacian(12, edges)
vals, vecs = np.linalg.eigh(L)
exact = vecs[:, 1] if vecs[0, 1] > 0 else -vecs[:, 1]
print("exact lambda_2 =", round(float(vals[1]), 6), " lambda_3 =", round(float(vals[2]), 6))
for it in [10, 50, 200]:
x, rq = fiedler_power(L, it)
x = x if x[0] > 0 else -x
print(f"{it:5} iterations: Rayleigh quotient {rq:.6f}, distance to the exact vector {float(np.linalg.norm(x - exact)):.2e}")
print("Fiedler vector:", np.round(exact, 3) + 0.0)exact lambda_2 = 0.117979 lambda_3 = 1.0
10 iterations: Rayleigh quotient 0.554771, distance to the exact vector 7.53e-01
50 iterations: Rayleigh quotient 0.118447, distance to the exact vector 2.30e-02
200 iterations: Rayleigh quotient 0.117979, distance to the exact vector 1.87e-08
Fiedler vector: [ 0.32 0.32 0.32 0.32 0.283 0.098 -0.098 -0.283 -0.32 -0.32
-0.32 -0.32 ]
The Rayleigh quotient is accurate long before the vector is, as predicted. The Fiedler vector is positive on one clique, negative on the other, and passes through zero along the connecting path.
In C++
The same deflated power iteration with a sparse adjacency list, so each step is .
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <random>
#include <vector>
using Graph = std::vector<std::vector<int>>;
// y = c x - L x for the unweighted Laplacian, from adjacency lists
void apply(const Graph& g, double c, const std::vector<double>& x, std::vector<double>& y) {
for (std::size_t v = 0; v < g.size(); ++v) {
double s = (c - double(g[v].size())) * x[v];
for (int u : g[v]) s += x[u];
y[v] = s;
}
}
int main() {
const int n = 12;
Graph g(n);
auto add = [&](int a, int b) { g[a].push_back(b); g[b].push_back(a); };
for (int s : {0, 7})
for (int a = 0; a < 5; ++a)
for (int b = a + 1; b < 5; ++b) add(a + s, b + s);
add(4, 5); add(5, 6); add(6, 7);
double c = 0;
for (auto& nb : g) c = std::max(c, 2.0 * double(nb.size()));
std::mt19937 rng(1); // a random start, uniform in [-0.5, 0.5)
std::vector<double> x(n), y(n);
for (double& v : x) v = double(rng()) / 4294967296.0 - 0.5;
for (int it = 1; it <= 1000; ++it) {
apply(g, c, x, y);
double mean = 0, norm = 0;
for (double v : y) mean += v / n;
for (double& v : y) { v -= mean; norm += v * v; }
for (int i = 0; i < n; ++i) x[i] = y[i] / std::sqrt(norm);
if (it == 10 || it == 100 || it == 1000) {
apply(g, 0.0, x, y); // y = -L x
double rq = 0;
for (int i = 0; i < n; ++i) rq -= x[i] * y[i];
std::printf("%4d iterations: lambda_2 estimate %.6f\n", it, rq);
}
}
double sign = x[0] > 0 ? 1.0 : -1.0;
std::printf("Fiedler vector:");
for (double v : x) std::printf(" %.3f", sign * v + 0.0);
std::printf("\n");
} 10 iterations: lambda_2 estimate 0.215155
100 iterations: lambda_2 estimate 0.117979
1000 iterations: lambda_2 estimate 0.117979
Fiedler vector: 0.320 0.320 0.320 0.320 0.283 0.098 -0.098 -0.283 -0.320 -0.320 -0.320 -0.320
Test yourself
By Courant-Fischer, which expression equals for a graph Laplacian?
A vector has Rayleigh quotient 0.3 for a graph's Laplacian. What follows?
- Nothing
You add an edge to a graph. What happens to the Laplacian eigenvalues?
- Only can grow
- Each stays the same or grows
- They can move in either direction
- Only changes
Deflated power iteration on converges to the Fiedler vector at which rate per step?