TExcelTAD
Home › Spectral Graph Theory & Modern Graph Algorithms › Spectra of Paths, Cycles, Complete Graphs and Hypercubes

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 λ2\lambda_2), 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, λ1≤⋯≤λn\lambda_1 \le \cdots \le \lambda_n are the eigenvalues of L=D−AL = D - A.

The complete graph

For KnK_n, A=J−IA = J - I where JJ is the all-ones matrix, so L=(n−1)I−(J−I)=nI−JL = (n-1)I - (J - I) = nI - J. Every vector x⊥1x \perp \mathbf{1} has Jx=0Jx = 0, hence Lx=nxLx = nx. So

spec⁡(LKn)={0,n,…,n⏟n−1}.\operatorname{spec}(L_{K_n}) = \{0, \underbrace{n, \ldots, n}_{n - 1}\}.

Every nonzero direction is "maximally rough": no vector orthogonal to 1\mathbf{1} can be smooth when every pair of vertices is adjacent.

The same trick handles the star K1,n−1K_{1,n-1}: vectors that are zero on the centre and sum to zero on the leaves have eigenvalue 1 (multiplicity n−2n - 2), and the remaining eigenvalue is nn (from tr⁡(L)=2m=2(n−1)\operatorname{tr}(L) = 2m = 2(n-1)). So its spectrum is {0,1,…,1,n}\{0, 1, \ldots, 1, n\}.

The cycle

Number the vertices of CnC_n by Zn\mathbb{Z}_n. For an integer kk, try xv=cos⁡(2πkv/n)x_v = \cos(2\pi k v/n):

(Lx)v=2xv−xv−1−xv+1=2cos⁡θv−2cos⁡θvcos⁡θ=(2−2cos⁡θ) xv,θ=2πkn,(Lx)_v = 2x_v - x_{v-1} - x_{v+1} = 2\cos\theta v - 2\cos\theta v \cos\theta = (2 - 2\cos\theta)\, x_v, \qquad \theta = \frac{2\pi k}{n},

using cos⁡(a−b)+cos⁡(a+b)=2cos⁡acos⁡b\cos(a - b) + \cos(a + b) = 2\cos a \cos b. The same holds for sin⁡(2πkv/n)\sin(2\pi k v/n). For k=0,1,…,⌊n/2⌋k = 0, 1, \ldots, \lfloor n/2 \rfloor these give nn linearly independent eigenvectors, so

spec⁡(LCn)={2−2cos⁡2πkn:k=0,1,…,n−1},\operatorname{spec}(L_{C_n}) = \left\{ 2 - 2\cos\frac{2\pi k}{n} : k = 0, 1, \ldots, n - 1 \right\},

each value with k≠0,n/2k \ne 0, n/2 appearing twice. In particular λ2=2−2cos⁡2πn≈4π2n2\lambda_2 = 2 - 2\cos\frac{2\pi}{n} \approx \frac{4\pi^2}{n^2}: tiny, which is why walks on a cycle mix in Θ(n2)\Theta(n^2) steps.

The path

The path PnP_n (vertices 0,…,n−10, \ldots, n-1) is a "folded" cycle. Take C2nC_{2n} and identify vertex vv with vertex 2n−1−v2n - 1 - v. An eigenvector of C2nC_{2n} that is symmetric under this reflection, xv=cos⁡(πk(v+1/2)n)x_v = \cos\big(\frac{\pi k (v + 1/2)}{n}\big), restricts to an eigenvector of PnP_n with the same eigenvalue, because the end vertex 00 sees its missing neighbour −1-1 through the fold as x−1=x0x_{-1} = x_0, and 2x0−x−1−x1=x0−x12x_0 - x_{-1} - x_1 = x_0 - x_1 is exactly the path's equation at a degree-1 vertex. Therefore

spec⁡(LPn)={2−2cos⁡πkn:k=0,1,…,n−1},λ2(Pn)=2−2cos⁡πn≈π2n2,\operatorname{spec}(L_{P_n}) = \left\{ 2 - 2\cos\frac{\pi k}{n} : k = 0, 1, \ldots, n - 1 \right\}, \qquad \lambda_2(P_n) = 2 - 2\cos\frac{\pi}{n} \approx \frac{\pi^2}{n^2},

all simple, with λ2\lambda_2 about a quarter of the cycle's. The eigenvector for λ2\lambda_2 is a half-period cosine, monotone along the path: the Fiedler vector "sorts" the path from one end to the other.

python · try it yourself
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 G□HG \square H has vertex set VG×VHV_G \times V_H, with (a,b)∼(a′,b)(a, b) \sim (a', b) when a∼a′a \sim a' in GG and (a,b)∼(a,b′)(a, b) \sim (a, b') when b∼b′b \sim b' in HH. Its Laplacian is

LG□H=LG⊗IH+IG⊗LH,L_{G \square H} = L_G \otimes I_{H} + I_{G} \otimes L_H ,

and if LGx=λxL_G x = \lambda x, LHy=μyL_H y = \mu y, then (LG⊗I+I⊗LH)(x⊗y)=(λ+μ)(x⊗y)(L_G \otimes I + I \otimes L_H)(x \otimes y) = (\lambda + \mu)(x \otimes y). The nGnHn_G n_H products x⊗yx \otimes y of eigenbases form an eigenbasis, so the eigenvalues of a product are all sums λi+μj\lambda_i + \mu_j. Grids are products of paths, tori products of cycles.

The hypercube QdQ_d has vertex set {0,1}d\{0, 1\}^d, with an edge between strings differing in one bit. It is the product of dd copies of K2K_2, whose Laplacian eigenvalues are 0 and 2. Summing one choice per factor:

spec⁡(LQd)={2k with multiplicity (dk):k=0,1,…,d}.\operatorname{spec}(L_{Q_d}) = \{ 2k \text{ with multiplicity } \tbinom{d}{k} : k = 0, 1, \ldots, d \}.

The eigenvectors are explicit: for S⊆{1,…,d}S \subseteq \{1, \ldots, d\}, χS(x)=(−1)∑i∈Sxi\chi_S(x) = (-1)^{\sum_{i \in S} x_i} has eigenvalue 2∣S∣2\lvert S \rvert, since flipping bit ii changes the sign of χS\chi_S exactly when i∈Si \in S. These are the characters of Z2d\mathbb{Z}_2^d (the Walsh-Hadamard basis). In particular λ2(Qd)=2\lambda_2(Q_d) = 2 for n=2dn = 2^d vertices: in degree-normalized terms (λ2/d=2/d\lambda_2/d = 2/d), much better than a cycle, much worse than a complete graph.

python · try it yourself
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 λ2\lambda_2 comes from the longer side: λ2(P4)+0\lambda_2(P_4) + 0. A long thin grid is as badly connected as its long path.

Summary table

Graph nn λ2\lambda_2 λn\lambda_n
complete KnK_n nn nn nn
star K1,n−1K_{1,n-1} nn 11 nn
cycle CnC_n nn 2−2cos⁡(2π/n)≈4π2/n22 - 2\cos(2\pi/n) \approx 4\pi^2/n^2 44 (nn even)
path PnP_n nn 2−2cos⁡(π/n)≈π2/n22 - 2\cos(\pi/n) \approx \pi^2/n^2 2+2cos⁡(π/n)2 + 2\cos(\pi/n)
hypercube QdQ_d 2d2^d 22 2d2d

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 KnK_n?

  1. 00 and n−1n - 1
  2. 00 once and nn with multiplicity n−1n - 1
  3. 0,1,…,n−10, 1, \ldots, n - 1
  4. nn only

How does λ2\lambda_2 of the cycle CnC_n behave as nn grows?

  1. It stays near 2
  2. It decays like 4π2/n24\pi^2/n^2
  3. It decays like 1/n1/n
  4. It grows like log⁡n\log n

Which eigenvalue does the character χS(x)=(−1)∑i∈Sxi\chi_S(x) = (-1)^{\sum_{i \in S} x_i} have on the hypercube QdQ_d?

  1. ∣S∣\lvert S \rvert
  2. 2∣S∣2\lvert S \rvert
  3. d−∣S∣d - \lvert S \rvert
  4. 2∣S∣2^{\lvert S \rvert}

What are the Laplacian eigenvalues of a Cartesian product G□HG \square H?

  1. Products λiμj\lambda_i \mu_j
  2. Sums λi+μj\lambda_i + \mu_j
  3. The union of both spectra
  4. Maxima max⁡(λi,μj)\max(\lambda_i, \mu_j)