TExcelTAD

Exercises

Fourteen problems covering the whole course: graph matrices and their spectra, Courant-Fischer, Cheeger's inequality, expanders and random walks, effective resistance and Laplacian solvers. Try each one on paper first. Every problem has a short Answer to check yourself against and a full Solution; several solutions include a program that confirms the result, which you can edit and run.

Tip: For an upper bound on λ2\lambda_2, guess a test vector orthogonal to 1\mathbf{1} and compute its Rayleigh quotient. For a lower bound you need something about every vector: Cheeger's inequality, a path argument, or an explicit spectrum.

# Exercise Practises
1 The star's spectrum Laplacian eigenvalues
2 Complete bipartite graphs Laplacian eigenvalues
3 λ2\lambda_2 and the minimum degree Courant-Fischer, test vectors
4 Two cliques and a bridge conductance, Cheeger
5 Bipartite symmetry normalized Laplacian
6 How long to mix? spectral gap and mixing
7 Independent sets in the Petersen graph expander mixing lemma
8 Ramanujan or not? Alon-Boppana
9 Resistance in the complete graph effective resistance, Foster
10 Commuting on a path commute time
11 Star to triangle Schur complement
12 Random spanning trees of K4K_4 matrix-tree theorem, leverage
13 CG on bigger grids conjugate gradient
14 How many samples? Spielman-Srivastava

Exercise 1: The star's spectrum

Find all Laplacian eigenvalues of the star K1,n−1K_{1,n-1} (centre 0, leaves 1,…,n−11, \ldots, n-1) with an eigenvector for each.

Answer

00 (eigenvector 1\mathbf{1}), 11 with multiplicity n−2n - 2 (vectors zero at the centre, summing to zero on the leaves), and nn (eigenvector x0=n−1x_0 = n - 1, xleaf=−1x_{\text{leaf}} = -1).

Solution

If x0=0x_0 = 0 and ∑leavesxi=0\sum_{\text{leaves}} x_i = 0, then (Lx)0=(n−1)x0−∑ixi=0(Lx)_0 = (n-1)x_0 - \sum_i x_i = 0 and (Lx)i=xi−x0=xi(Lx)_i = x_i - x_0 = x_i: eigenvalue 1, and these vectors form an (n−2)(n - 2)-dimensional space. For x=(n−1,−1,…,−1)x = (n - 1, -1, \ldots, -1): (Lx)0=(n−1)2+(n−1)=n(n−1)(Lx)_0 = (n-1)^2 + (n - 1) = n(n-1) and (Lx)i=−1−(n−1)=−n(Lx)_i = -1 - (n - 1) = -n, so Lx=nxLx = nx. The trace check: 0+(n−2)+n=2(n−1)=2m0 + (n - 2) + n = 2(n - 1) = 2m.

Exercise 2: Complete bipartite graphs

Show that the Laplacian of Ka,bK_{a,b} has eigenvalues 00, aa (multiplicity b−1b - 1), bb (multiplicity a−1a - 1) and a+ba + b. What is the algebraic connectivity of K3,5K_{3,5}?

Answer

a(K3,5)=min⁡(a,b)=3a(K_{3,5}) = \min(a, b) = 3.

Solution

A vertex on side AA (size aa) has degree bb, on side BB degree aa. A vector that is zero on AA and sums to zero on BB satisfies (Lx)v=axv(Lx)_v = a x_v for v∈Bv \in B (each BB-vertex sees only AA, where x=0x = 0) and (Lx)u=−∑v∈Bxv=0(Lx)_u = -\sum_{v \in B}x_v = 0 for u∈Au \in A: eigenvalue aa, multiplicity b−1b - 1. Symmetrically bb with multiplicity a−1a - 1. The vector x=bx = b on AA, −a-a on BB has (Lx)u=b⋅b+ab=b(a+b)(Lx)_u = b \cdot b + ab = b(a+b) for u∈Au \in A: eigenvalue a+ba + b. With 1\mathbf{1} that is 1+(b−1)+(a−1)+1=a+b1 + (b-1) + (a-1) + 1 = a + b eigenvalues.

python · try it yourself
import numpy as np

a, b = 3, 5
n = a + b
L = np.zeros((n, n))
for u in range(a):
    for v in range(a, n):
        L[u, u] += 1; L[v, v] += 1; L[u, v] -= 1; L[v, u] -= 1
print(np.round(np.linalg.eigvalsh(L), 6) + 0.0)
[0. 3. 3. 3. 3. 5. 5. 8.]

Exercise 3: λ2\lambda_2 and the minimum degree

Prove that every graph on nn vertices satisfies λ2(L)≤nn−1dmin⁡\lambda_2(L) \le \frac{n}{n-1} d_{\min} (unweighted). When is it tight?

Answer

Use the test vector x=ev−1n1x = \mathbf{e}_v - \frac1n\mathbf{1} for a vertex vv of minimum degree. Tight for KnK_n: λ2=n=nn−1(n−1)\lambda_2 = n = \frac{n}{n-1}(n-1).

Solution

x⊥1x \perp \mathbf{1}, and since L1=0L\mathbf{1} = 0, xTLx=evTLev=dvx^{\mathsf{T}} L x = \mathbf{e}_v^{\mathsf{T}} L \mathbf{e}_v = d_v. Also xTx=(1−1n)2+(n−1)1n2=n−1nx^{\mathsf{T}} x = (1 - \frac1n)^2 + (n - 1)\frac{1}{n^2} = \frac{n-1}{n}. Courant-Fischer gives λ2≤dv(n−1)/n=n dmin⁡n−1\lambda_2 \le \frac{d_v}{(n-1)/n} = \frac{n\, d_{\min}}{n - 1}. With Fiedler's inequality λ2≤κ(G)≤dmin⁡\lambda_2 \le \kappa(G) \le d_{\min} for non-complete graphs, the bound is only interesting for KnK_n, where it is exact.

Exercise 4: Two cliques and a bridge

Two copies of K4K_4 are joined by one edge (8 vertices, 13 edges). (a) Compute ϕ(G)\phi(G) with the course's definition. (b) Use Cheeger's inequality to bound ν2\nu_2 from both sides. (c) Check numerically.

Answer

(a) ϕ=1/13\phi = 1/13 (each side has volume 2⋅6+1=132 \cdot 6 + 1 = 13). (b) ϕ22≤ν2≤2ϕ\frac{\phi^2}{2} \le \nu_2 \le 2\phi, i.e. 0.00296≤ν2≤0.15380.00296 \le \nu_2 \le 0.1538. (c) ν2≈0.1134\nu_2 \approx 0.1134.

Solution

Any other cut separates part of a clique and costs at least 3 edges for at most the same volume, so the bridge cut is optimal: ϕ=1/13\phi = 1/13. Cheeger's inequality ν22≤ϕ≤2ν2\frac{\nu_2}{2} \le \phi \le \sqrt{2\nu_2} rearranges to ϕ22≤ν2≤2ϕ\frac{\phi^2}{2} \le \nu_2 \le 2\phi. The true value lies in between, closer to the upper end, as for most graphs with a single clear bottleneck.

python · try it yourself
import numpy as np

edges = [(a + s, b + s) for s in (0, 4) for a in range(4) for b in range(a + 1, 4)] + [(3, 4)]
A = np.zeros((8, 8))
for u, v in edges:
    A[u, v] = A[v, u] = 1
s = 1 / np.sqrt(A.sum(axis=1))
nu2 = float(np.linalg.eigvalsh(np.eye(8) - s[:, None] * A * s[None, :])[1])
phi = 1 / 13
print(f"phi^2/2 = {phi ** 2 / 2:.5f} <= nu_2 = {nu2:.5f} <= 2 phi = {2 * phi:.5f}")
phi^2/2 = 0.00296 <= nu_2 = 0.11338 <= 2 phi = 0.15385

Exercise 5: Bipartite symmetry

Let GG be bipartite with sides X,YX, Y, and let yy be an eigenvector of the normalized Laplacian NN with eigenvalue ν\nu. Show that flipping the sign of yy on YY gives an eigenvector with eigenvalue 2−ν2 - \nu.

Answer

With S=diag⁡(±1)S = \operatorname{diag}(\pm 1) (+1+1 on XX, −1-1 on YY), S(I−N)S=−(I−N)S(I - N)S = -(I - N), so N(Sy)=(2−ν)SyN(Sy) = (2 - \nu)Sy.

Solution

M=D−1/2AD−1/2=I−NM = D^{-1/2}AD^{-1/2} = I - N has nonzero entries only between XX and YY. With S=diag⁡(sv)S = \operatorname{diag}(s_v), sv=1s_v = 1 on XX and −1-1 on YY, every entry MuvM_{uv} is multiplied by susv=−1s_us_v = -1, so SMS=−MSMS = -M. If My=(1−ν)yMy = (1 - \nu)y, then, using S2=IS^2 = I, M(Sy)=S(SMS)y=−SMy=−(1−ν)SyM(Sy) = S(SMS)y = -SMy = -(1 - \nu)Sy. So N(Sy)=(1+(1−ν))Sy=(2−ν)SyN(Sy) = (1 + (1 - \nu))Sy = (2 - \nu)Sy. In particular νn=2\nu_n = 2 (from ν1=0\nu_1 = 0), as in The Normalized Laplacian.

Exercise 6: How long to mix?

A connected 8-regular graph has 10610^6 vertices and normalized Laplacian eigenvalue ν2=0.02\nu_2 = 0.02. Bound the number of lazy-walk steps after which the total-variation distance from any start is at most 14\frac14.

Answer

t≤2ν2ln⁡n2ε=100ln⁡(2×106)≈1451t \le \frac{2}{\nu_2}\ln\frac{n}{2\varepsilon} = 100\ln(2 \times 10^6) \approx 1451 steps.

Solution

From Mixing of Random Walks via the Spectral Gap, ∥pt−π∥TV≤n2dmax⁡/dmin⁡ (1−ν2/2)t≤n2e−tν2/2\lVert p_t - \pi \rVert_{TV} \le \frac n2\sqrt{d_{\max}/d_{\min}}\,(1 - \nu_2/2)^t \le \frac n2 e^{-t\nu_2/2} for a regular graph. Setting this to 14\frac14 gives t=2ν2ln⁡(2n)=100⋅14.51t = \frac{2}{\nu_2}\ln(2n) = 100 \cdot 14.51. The lower bound (2ν2−1)ln⁡2≈68(\frac{2}{\nu_2} - 1)\ln 2 \approx 68 shows the truth is between 68 and 1451 steps.

Exercise 7: Independent sets in the Petersen graph

The Petersen graph is 3-regular on 10 vertices with adjacency eigenvalues 3,1,−23, 1, -2. Bound its independence number with the expander mixing lemma and with Hoffman's bound.

Answer

λ=2\lambda = 2: the mixing lemma gives α≤λd+λn=4\alpha \le \frac{\lambda}{d + \lambda}n = 4; Hoffman gives −μnd−μnn=25⋅10=4\frac{-\mu_n}{d - \mu_n}n = \frac25 \cdot 10 = 4. The true value is 4.

Solution

For an independent SS, e(S,S)=0e(S, S) = 0 and the expander mixing lemma gives d∣S∣2n≤λ∣S∣(1−∣S∣n)\frac{d\lvert S \rvert^2}{n} \le \lambda\lvert S \rvert(1 - \frac{\lvert S \rvert}{n}), so ∣S∣≤λnd+λ=205\lvert S \rvert \le \frac{\lambda n}{d + \lambda} = \frac{20}{5}. With the labelling of the lesson (outer cycle 0,…,40, \ldots, 4, inner pentagram 5,…,95, \ldots, 9, spokes ii-(i+5)(i+5)), the set {0,2,8,9}\{0, 2, 8, 9\} is independent, so both bounds are tight.

Exercise 8: Ramanujan or not?

A 5-regular graph on 1000 vertices has adjacency eigenvalues μ2=3.9\mu_2 = 3.9 and μn=−3.2\mu_n = -3.2. Is it Ramanujan? Could a 5-regular graph on 10910^9 vertices have μ2=3.5\mu_2 = 3.5?

Answer

It is Ramanujan: λ=3.9≤24=4\lambda = 3.9 \le 2\sqrt{4} = 4. A 5-regular graph on 10910^9 vertices with μ2=3.5\mu_2 = 3.5 cannot exist, by Alon-Boppana.

Solution

λ=max⁡(3.9,3.2)=3.9≤2d−1=4\lambda = \max(3.9, 3.2) = 3.9 \le 2\sqrt{d-1} = 4, so the graph is Ramanujan. For the second question, use Nilli's form, which needs two edges far apart. Fix an edge ee. At most 2(1+4+42+⋯+414)=2(415−1)3≈7.2×108<1092(1 + 4 + 4^2 + \cdots + 4^{14}) = \frac{2(4^{15} - 1)}{3} \approx 7.2 \times 10^8 < 10^9 vertices lie within distance 14 of ee, so some vertex ww is at distance at least 15 from ee, and every edge at ww is at distance at least 14=2k+214 = 2k + 2 from ee with k=6k = 6. Hence μ2≥4−4−17≈3.57>3.5\mu_2 \ge 4 - \frac{4 - 1}{7} \approx 3.57 > 3.5. No such graph exists (Constructing Expanders).

Exercise 9: Resistance in the complete graph

Find Reff(u,v)R_{\text{eff}}(u, v) for any two vertices of KnK_n (unit resistors) in two ways: by symmetry and Foster's theorem, and from L+L^+.

Answer

Reff=2nR_{\text{eff}} = \frac{2}{n}.

Solution

By symmetry all (n2)\binom n2 edges have the same resistance RR, and Foster's theorem gives (n2)R=n−1\binom n2 R = n - 1, so R=2nR = \frac2n. Alternatively L=nI−JL = nI - J and L+=1n(I−1nJ)L^+ = \frac1n(I - \frac1nJ), so R=(L+)uu+(L+)vv−2(L+)uv=1n(2(1−1n)+2n)=2nR = (L^+)_{uu} + (L^+)_{vv} - 2(L^+)_{uv} = \frac1n(2(1 - \frac1n) + \frac2n) = \frac2n. Physically: the direct edge (1 ohm) in parallel with n−2n - 2 two-edge paths that, by symmetry, all meet at the same middle potential.

Exercise 10: Commuting on a path

Compute the expected commute time between the two ends of the path PnP_n (nn vertices) and the expected hitting time from one end to the other.

Answer

Commute time 2(n−1)⋅(n−1)=2(n−1)22(n-1) \cdot (n-1) = 2(n-1)^2; hitting time (n−1)2(n-1)^2 each way.

Solution

m=n−1m = n - 1 and Reff=n−1R_{\text{eff}} = n - 1 (resistors in series), so κ=2mReff=2(n−1)2\kappa = 2mR_{\text{eff}} = 2(n-1)^2 by the theorem of Chandra et al. (Effective Resistance). By the symmetry of the path the two hitting times are equal, each (n−1)2(n - 1)^2: the familiar fact that a simple random walk needs about k2k^2 steps to travel distance kk.

Exercise 11: Star to triangle

A vertex cc is joined to aa, bb, dd by resistors of 11, 22 and 33 ohms. Eliminate cc. What are the resistances of the resulting triangle?

Answer

Conductances 1,12,131, \frac12, \frac13, total 116\frac{11}{6}. New conductances wawb/Σ=311w_aw_b/\Sigma = \frac{3}{11}, wawd/Σ=211w_aw_d/\Sigma = \frac{2}{11}, wbwd/Σ=111w_bw_d/\Sigma = \frac{1}{11}; resistances 113\frac{11}{3}, 112\frac{11}{2} and 1111 ohms.

Solution

By the star-mesh rule of Gaussian Elimination and Schur Complements, each pair of neighbours gets conductance wxwydc\frac{w_xw_y}{d_c} with dc=1+12+13=116d_c = 1 + \frac12 + \frac13 = \frac{11}{6}: aa-bb: 1/211/6=311\frac{1/2}{11/6} = \frac3{11}; aa-dd: 1/311/6=211\frac{1/3}{11/6} = \frac2{11}; bb-dd: 1/611/6=111\frac{1/6}{11/6} = \frac1{11}. Check: in the star, with dd left floating, R(a,b)=1+2=3R(a, b) = 1 + 2 = 3; in the triangle, 113\frac{11}{3} in parallel with 112+11=332\frac{11}{2} + 11 = \frac{33}{2} gives (11/3)(33/2)11/3+33/2=3\frac{(11/3)(33/2)}{11/3 + 33/2} = 3.

Exercise 12: Random spanning trees of K4K_4

(a) How many spanning trees does K4K_4 have? (b) What is the probability that a fixed edge is in a uniformly random one? (c) Compare with ReffR_{\text{eff}}.

Answer

(a) 16. (b) 816=12\frac{8}{16} = \frac12. (c) Reff=24=12R_{\text{eff}} = \frac24 = \frac12, as Kirchhoff's theorem says.

Solution

By the matrix-tree theorem, the count is any cofactor of L=4I−JL = 4I - J: det⁡(4I3−J3)=4⋅4⋅(4−3)=16\det(4I_3 - J_3) = 4 \cdot 4 \cdot (4 - 3) = 16 (Cayley: nn−2=16n^{n-2} = 16). Each tree has 3 of the 6 edges, and by symmetry every edge is in the same number of trees: 16⋅3/6=816 \cdot 3/6 = 8.

python · try it yourself
import itertools
import numpy as np

E = list(itertools.combinations(range(4), 2))
def is_tree(es):
    parent = list(range(4))
    def find(a):
        while parent[a] != a:
            a = parent[a]
        return a
    for u, v in es:
        a, b = find(u), find(v)
        if a == b:
            return False
        parent[a] = b
    return True
trees = [T for T in itertools.combinations(E, 3) if is_tree(T)]
print("spanning trees:", len(trees), " containing edge (0,1):", sum((0, 1) in T for T in trees))
L = 4 * np.eye(4) - np.ones((4, 4))
P = np.linalg.pinv(L)
print("R_eff(0,1) =", round(float(P[0, 0] + P[1, 1] - 2 * P[0, 1]), 6))
spanning trees: 16  containing edge (0,1): 8
R_eff(0,1) = 0.5

Exercise 13: CG on bigger grids

Conjugate gradient needs 86 iterations on a 32×3232 \times 32 grid for a fixed tolerance. Roughly how many on a 256×256256 \times 256 grid? How many for Gauss-Seidel-like methods whose iterations scale with κ\kappa?

Answer

About 86×8≈70086 \times 8 \approx 700 for CG (κ∝k\sqrt\kappa \propto k); for κ\kappa-scaling methods the count grows by 6464.

Solution

For a k×kk \times k grid κ=λn/λ2≈8k2/π2\kappa = \lambda_n/\lambda_2 \approx 8k^2/\pi^2. Going from k=32k = 32 to 256256 multiplies κ\kappa by 64 and κ\sqrt\kappa by 8, which is the scaling of CG's bound O(κlog⁡(1/ε))O(\sqrt\kappa\log(1/\varepsilon)) (Conjugate Gradient). Methods with O(κlog⁡(1/ε))O(\kappa\log(1/\varepsilon)) iterations grow 64-fold. With n=65 536n = 65\,536 unknowns, CG's total work is O(n1.5)O(n^{1.5}); a nearly-linear solver would be O~(n)\tilde O(n).

Exercise 14: How many samples?

Using the concentration bound of Sparsification by Effective Resistances, q≥3(n−1)ln⁡(2n2)/ε2q \ge 3(n-1)\ln(2n^2)/\varepsilon^2, how many samples guarantee a (1±0.1)(1 \pm 0.1)-sparsifier of a graph with n=104n = 10^4 vertices? Is it worth it for G=KnG = K_n? For a graph with average degree 20?

Answer

q≈3⋅9999⋅ln⁡(2×108)/0.01≈5.7×107q \approx 3 \cdot 9999 \cdot \ln(2 \times 10^8)/0.01 \approx 5.7 \times 10^7 samples. Not even for KnK_n: it has only about 5×1075 \times 10^7 edges, fewer than the samples. Certainly not for average degree 20 (10510^5 edges).

Solution

ln⁡(2×108)≈19.1\ln(2 \times 10^8) \approx 19.1, so q≈3⋅9999⋅19.1⋅100≈5.73×107q \approx 3 \cdot 9999 \cdot 19.1 \cdot 100 \approx 5.73 \times 10^7. K104K_{10^4} has (1042)≈5×107\binom{10^4}{2} \approx 5 \times 10^7 edges, so the worst-case constant makes the guarantee useless at this size; in practice far fewer samples suffice, and Batson-Spielman-Srivastava's O(n/ε2)O(n/\varepsilon^2) removes the logarithm. Sparsification is a tool for very dense graphs or for theory; a graph with 10510^5 edges is already sparse.

Test yourself

Which test vector proves λ2≤nn−1dmin⁡\lambda_2 \le \frac{n}{n-1}d_{\min}?

  1. 1\mathbf{1}
  2. ev−1n1\mathbf{e}_v - \frac1n\mathbf{1} for a minimum-degree vertex vv
  3. The degree vector
  4. A random vector

What is the effective resistance between two vertices of KnK_n?

  1. 11
  2. 2n\frac{2}{n}
  3. 1n−1\frac{1}{n-1}
  4. nn

What is the expected commute time between the ends of the path PnP_n?

  1. n−1n - 1
  2. 2(n−1)22(n-1)^2
  3. n3n^3
  4. 2n2n