Spectra of Paths, Cycles, Complete Graphs and Hypercubes
Before using eigenvalues to analyse unknown graphs, it pays to know them exactly for a few families. They are the yardsticks of the subject: the path and the cycle are the worst-connected graphs of their size (tiny ), the complete graph the best, and the hypercube sits in between with a clean combinatorial structure. Each spectrum here is derived by guessing an eigenvector and checking it, and then confirmed numerically. Throughout, are the eigenvalues of .
The complete graph
For , where is the all-ones matrix, so . Every vector has , hence . So
Every nonzero direction is "maximally rough": no vector orthogonal to can be smooth when every pair of vertices is adjacent.
The same trick handles the star : vectors that are zero on the centre and sum to zero on the leaves have eigenvalue 1 (multiplicity ), and the remaining eigenvalue is (from ). So its spectrum is .
The cycle
Number the vertices of by . For an integer , try :
using . The same holds for . For these give linearly independent eigenvectors, so
each value with appearing twice. In particular : tiny, which is why walks on a cycle mix in steps.
The path
The path (vertices ) is a "folded" cycle. Take and identify vertex with vertex . An eigenvector of that is symmetric under this reflection, , restricts to an eigenvector of with the same eigenvalue, because the end vertex sees its missing neighbour through the fold as , and is exactly the path's equation at a degree-1 vertex. Therefore
all simple, with about a quarter of the cycle's. The eigenvector for is a half-period cosine, monotone along the path: the Fiedler vector "sorts" the path from one end to the other.
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
n = 8
path = laplacian(n, [(i, i + 1) for i in range(n - 1)])
cycle = laplacian(n, [(i, (i + 1) % n) for i in range(n)])
k = np.arange(n)
print("path numeric:", np.round(np.linalg.eigvalsh(path), 4) + 0.0)
print("path formula:", np.round(np.sort(2 - 2 * np.cos(np.pi * k / n)), 4) + 0.0)
print("cycle numeric:", np.round(np.linalg.eigvalsh(cycle), 4) + 0.0)
print("cycle formula:", np.round(np.sort(2 - 2 * np.cos(2 * np.pi * k / n)), 4) + 0.0)
x = np.cos(np.pi * (np.arange(n) + 0.5) / n) # the guessed Fiedler vector of the path
lam2 = 2 - 2 * np.cos(np.pi / n)
print("path: L x = lambda_2 x ?", bool(np.allclose(path @ x, lam2 * x)), " x =", np.round(x, 3) + 0.0)
for size in [10, 100, 1000]:
print(f"n = {size:4}: lambda_2(path) = {2 - 2 * np.cos(np.pi / size):.3e}, pi^2 / n^2 = {np.pi ** 2 / size ** 2:.3e}")path numeric: [0. 0.1522 0.5858 1.2346 2. 2.7654 3.4142 3.8478]
path formula: [0. 0.1522 0.5858 1.2346 2. 2.7654 3.4142 3.8478]
cycle numeric: [0. 0.5858 0.5858 2. 2. 3.4142 3.4142 4. ]
cycle formula: [0. 0.5858 0.5858 2. 2. 3.4142 3.4142 4. ]
path: L x = lambda_2 x ? True x = [ 0.981 0.831 0.556 0.195 -0.195 -0.556 -0.831 -0.981]
n = 10: lambda_2(path) = 9.789e-02, pi^2 / n^2 = 9.870e-02
n = 100: lambda_2(path) = 9.869e-04, pi^2 / n^2 = 9.870e-04
n = 1000: lambda_2(path) = 9.870e-06, pi^2 / n^2 = 9.870e-06
Products and the hypercube
The Cartesian product has vertex set , with when in and when in . Its Laplacian is
and if , , then . The products of eigenbases form an eigenbasis, so the eigenvalues of a product are all sums . Grids are products of paths, tori products of cycles.
The hypercube has vertex set , with an edge between strings differing in one bit. It is the product of copies of , whose Laplacian eigenvalues are 0 and 2. Summing one choice per factor:
The eigenvectors are explicit: for , has eigenvalue , since flipping bit changes the sign of exactly when . These are the characters of (the Walsh-Hadamard basis). In particular for vertices: in degree-normalized terms (), much better than a cycle, much worse than a complete graph.
import itertools
from collections import Counter
from math import comb
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
d = 5
n = 2 ** d
edges = [(x, x ^ (1 << i)) for x in range(n) for i in range(d) if x < x ^ (1 << i)]
L = laplacian(n, edges)
lam = np.round(np.linalg.eigvalsh(L), 6) + 0.0
print("Q_5 eigenvalue: multiplicity (binomial)")
for value, count in sorted(Counter(lam.tolist()).items()):
print(f" {value:4.1f}: {count:2} ({comb(d, int(value) // 2)})")
S = [0, 2, 3] # character chi_S, expected eigenvalue 2|S| = 6
chi = np.array([(-1) ** sum((x >> i) & 1 for i in S) for x in range(n)], dtype=float)
print("chi_S with S = {0, 2, 3}: L chi = 6 chi ?", bool(np.allclose(L @ chi, 6 * chi)))
# product rule on a 3 x 4 grid = P_3 x P_4
P3 = laplacian(3, [(0, 1), (1, 2)])
P4 = laplacian(4, [(0, 1), (1, 2), (2, 3)])
grid = np.kron(P3, np.eye(4)) + np.kron(np.eye(3), P4)
sums = sorted(a + b for a, b in itertools.product(np.linalg.eigvalsh(P3), np.linalg.eigvalsh(P4)))
print("grid 3x4 equals sums of path eigenvalues:", bool(np.allclose(np.linalg.eigvalsh(grid), sums)))
print("grid lambda_2 =", round(float(np.linalg.eigvalsh(grid)[1]), 4), "= lambda_2(P_4) =", round(2 - 2 * float(np.cos(np.pi / 4)), 4))Q_5 eigenvalue: multiplicity (binomial)
0.0: 1 (1)
2.0: 5 (5)
4.0: 10 (10)
6.0: 10 (10)
8.0: 5 (5)
10.0: 1 (1)
chi_S with S = {0, 2, 3}: L chi = 6 chi ? True
grid 3x4 equals sums of path eigenvalues: True
grid lambda_2 = 0.5858 = lambda_2(P_4) = 0.5858
The grid's comes from the longer side: . A long thin grid is as badly connected as its long path.
Summary table
| Graph | |||
|---|---|---|---|
| complete | |||
| star | |||
| cycle | ( even) | ||
| path | |||
| hypercube |
The table is worth memorizing, because almost every bound in the course is tested against it: Cheeger's inequality is tight up to constants on the cycle (on one side) and the hypercube (on the other), and the path is the extreme case for mixing.
Test yourself
What are the Laplacian eigenvalues of ?
- and
- once and with multiplicity
- only
How does of the cycle behave as grows?
- It stays near 2
- It decays like
- It decays like
- It grows like
Which eigenvalue does the character have on the hypercube ?
What are the Laplacian eigenvalues of a Cartesian product ?
- Products
- Sums
- The union of both spectra
- Maxima