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 , guess a test vector orthogonal to 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 | 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 | 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 (centre 0, leaves ) with an eigenvector for each.
Answer
(eigenvector ), with multiplicity (vectors zero at the centre, summing to zero on the leaves), and (eigenvector , ).
Solution
If and , then and : eigenvalue 1, and these vectors form an -dimensional space. For : and , so . The trace check: .
Exercise 2: Complete bipartite graphs
Show that the Laplacian of has eigenvalues , (multiplicity ), (multiplicity ) and . What is the algebraic connectivity of ?
Answer
.
Solution
A vertex on side (size ) has degree , on side degree . A vector that is zero on and sums to zero on satisfies for (each -vertex sees only , where ) and for : eigenvalue , multiplicity . Symmetrically with multiplicity . The vector on , on has for : eigenvalue . With that is eigenvalues.
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: and the minimum degree
Prove that every graph on vertices satisfies (unweighted). When is it tight?
Answer
Use the test vector for a vertex of minimum degree. Tight for : .
Solution
, and since , . Also . Courant-Fischer gives . With Fiedler's inequality for non-complete graphs, the bound is only interesting for , where it is exact.
Exercise 4: Two cliques and a bridge
Two copies of are joined by one edge (8 vertices, 13 edges). (a) Compute with the course's definition. (b) Use Cheeger's inequality to bound from both sides. (c) Check numerically.
Answer
(a) (each side has volume ). (b) , i.e. . (c) .
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: . Cheeger's inequality rearranges to . The true value lies in between, closer to the upper end, as for most graphs with a single clear bottleneck.
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 be bipartite with sides , and let be an eigenvector of the normalized Laplacian with eigenvalue . Show that flipping the sign of on gives an eigenvector with eigenvalue .
Answer
With ( on , on ), , so .
Solution
has nonzero entries only between and . With , on and on , every entry is multiplied by , so . If , then, using , . So . In particular (from ), as in The Normalized Laplacian.
Exercise 6: How long to mix?
A connected 8-regular graph has vertices and normalized Laplacian eigenvalue . Bound the number of lazy-walk steps after which the total-variation distance from any start is at most .
Answer
steps.
Solution
From Mixing of Random Walks via the Spectral Gap, for a regular graph. Setting this to gives . The lower bound 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 . Bound its independence number with the expander mixing lemma and with Hoffman's bound.
Answer
: the mixing lemma gives ; Hoffman gives . The true value is 4.
Solution
For an independent , and the expander mixing lemma gives , so . With the labelling of the lesson (outer cycle , inner pentagram , spokes -), the set is independent, so both bounds are tight.
Exercise 8: Ramanujan or not?
A 5-regular graph on 1000 vertices has adjacency eigenvalues and . Is it Ramanujan? Could a 5-regular graph on vertices have ?
Answer
It is Ramanujan: . A 5-regular graph on vertices with cannot exist, by Alon-Boppana.
Solution
, so the graph is Ramanujan. For the second question, use Nilli's form, which needs two edges far apart. Fix an edge . At most vertices lie within distance 14 of , so some vertex is at distance at least 15 from , and every edge at is at distance at least from with . Hence . No such graph exists (Constructing Expanders).
Exercise 9: Resistance in the complete graph
Find for any two vertices of (unit resistors) in two ways: by symmetry and Foster's theorem, and from .
Answer
.
Solution
By symmetry all edges have the same resistance , and Foster's theorem gives , so . Alternatively and , so . Physically: the direct edge (1 ohm) in parallel with 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 ( vertices) and the expected hitting time from one end to the other.
Answer
Commute time ; hitting time each way.
Solution
and (resistors in series), so by the theorem of Chandra et al. (Effective Resistance). By the symmetry of the path the two hitting times are equal, each : the familiar fact that a simple random walk needs about steps to travel distance .
Exercise 11: Star to triangle
A vertex is joined to , , by resistors of , and ohms. Eliminate . What are the resistances of the resulting triangle?
Answer
Conductances , total . New conductances , , ; resistances , and ohms.
Solution
By the star-mesh rule of Gaussian Elimination and Schur Complements, each pair of neighbours gets conductance with : -: ; -: ; -: . Check: in the star, with left floating, ; in the triangle, in parallel with gives .
Exercise 12: Random spanning trees of
(a) How many spanning trees does have? (b) What is the probability that a fixed edge is in a uniformly random one? (c) Compare with .
Answer
(a) 16. (b) . (c) , as Kirchhoff's theorem says.
Solution
By the matrix-tree theorem, the count is any cofactor of : (Cayley: ). Each tree has 3 of the 6 edges, and by symmetry every edge is in the same number of trees: .
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 grid for a fixed tolerance. Roughly how many on a grid? How many for Gauss-Seidel-like methods whose iterations scale with ?
Answer
About for CG (); for -scaling methods the count grows by .
Solution
For a grid . Going from to multiplies by 64 and by 8, which is the scaling of CG's bound (Conjugate Gradient). Methods with iterations grow 64-fold. With unknowns, CG's total work is ; a nearly-linear solver would be .
Exercise 14: How many samples?
Using the concentration bound of Sparsification by Effective Resistances, , how many samples guarantee a -sparsifier of a graph with vertices? Is it worth it for ? For a graph with average degree 20?
Answer
samples. Not even for : it has only about edges, fewer than the samples. Certainly not for average degree 20 ( edges).
Solution
, so . has edges, so the worst-case constant makes the guarantee useless at this size; in practice far fewer samples suffice, and Batson-Spielman-Srivastava's removes the logarithm. Sparsification is a tool for very dense graphs or for theory; a graph with edges is already sparse.
Test yourself
Which test vector proves ?
- for a minimum-degree vertex
- The degree vector
- A random vector
What is the effective resistance between two vertices of ?
What is the expected commute time between the ends of the path ?