Module contents
Lesson 3 of 30Core 110 min

The graph spectrum: algebraic connectivity, Fiedler and Cheeger

Study Laplacian spectra, algebraic connectivity, Fiedler vectors, Cheeger's inequality and sweep cuts, then connect expansion to random-walk mixing.

After this lesson you can

  • Calculate and recognize the spectra of paths, cycles, grids, complete graphs and stars.
  • Characterize the second eigenvalue with Courant-Fischer and prove that it is positive exactly when the graph is connected.
  • Define conductance and prove the lower Cheeger bound.
  • Implement a Fiedler sweep cut and empirically verify the upper Cheeger bound.
  • Explain expanders and how their spectral gap relates to mixing and bottlenecks.

Before you start

Finding a bottleneck without enumerating cuts

If two groups of services are connected by a single link, failure of that link separates them. There are 2n−1−12^{n-1}-1 nontrivial cuts when each set is identified with its complement. Enumerating them costs exponential time, but an eigenvector provides a continuous coordinate for ordering nodes and proposing cuts. Add bridges in the figure. The displayed value comes from the normalized Laplacian; colors represent coordinates of the associated random-walk vector.

InteractiveA bottleneck between two communities
12345678

Azul: coordenada negativa; rojo: positiva. El signo global es arbitrario. Los puentes son azules y gruesos.

Bridges1
Normalized λ₂0.1134
Enable or disable bridges. Each group is a four-node clique. With no bridges there are two components and the second eigenvalue is zero; the direction chosen within the kernel is then not unique.

We use finite, simple, undirected graphs with positive edge weights. In the conductance section we also assume that the graph is connected and has at least two nodes, so all degrees are positive. The combinatorial Laplacian is L=D−A\mat{L}=\mat{D}-\mat{A}; distinguishing it from Lsym\mat{L}_{\mathrm{sym}} is essential.

Spectra that can be calculated

Spectra of graph families provide consistency checks for numerical algorithms. The following are eigenvalues of the unnormalized Laplacian, with edges of weight 1:

  • Path PnP_n: 2−2cos⁡(πk/n)2-2\cos(\pi k/n) for k=0,…,n−1k=0,\ldots,n-1.
  • Cycle CnC_n, n≥3n\ge3: 2−2cos⁡(2πk/n)2-2\cos(2\pi k/n) for k=0,…,n−1k=0,\ldots,n-1.
  • Grid Pa□PbP_a\square P_b: all sums of an eigenvalue of PaP_a and one of PbP_b.
  • Complete KnK_n: 0 once and nn with multiplicity n−1n-1.
  • Star K1,n−1K_{1,n-1}, n≥3n\ge3: 0 once, 1 with multiplicity n−2n-2 and nn once.

On the cycle, discrete Fourier transform modes uj(k)=e2πikj/nu_j^{(k)}=e^{2\pi\mathrm{i}kj/n} with indices j=0,…,n−1j=0,\ldots,n-1 diagonalize L\mat{L}. The two neighbors contribute uj−1+uj+1=2cos⁡(2πk/n)uju_{j-1}+u_{j+1}=2\cos(2\pi k/n)u_j, so Lu(k)=[2−2cos⁡(2πk/n)]u(k)\mat{L}\vb{u}^{(k)}=[2-2\cos(2\pi k/n)]\vb{u}^{(k)}. Conjugate complex modes share an eigenvalue; real sines and cosines can be used as a basis of the same subspace. On a path, cosine modes satisfy the degree-one endpoints, changing the denominator from 2πk/n2\pi k/n to πk/n\pi k/n.

The grid is a Cartesian product: its Laplacian is LPa⊗Ib+Ia⊗LPb\mat{L}_{P_a}\otimes\mat{I}_b+\mat{I}_a\otimes\mat{L}_{P_b}. On u⊗v\vb{u}\otimes\vb{v} it acts as (λu+λv)(u⊗v)(\lambda_u+\lambda_v)(\vb{u}\otimes\vb{v}). For KnK_n, L=nI−11⊤\mat{L}=n\mat{I}-\vb{1}\vb{1}\T: it annihilates the constant and multiplies any vector orthogonal to it by nn. The star was analyzed in the previous lesson.

InteractiveFamilies and modes

Rojo: coordenada positiva; azul: negativa. La intensidad se escala al máximo absoluto.

08

El punto magenta es el modo elegido. La rejilla usa 3×3 si n ≤ 8 y 4×4 si n ≥ 10. El regular se obtiene sumando al ciclo un emparejamiento perfecto sin duplicados; es una muestra de esta familia, no un regular uniforme.

8
2
Actual nodes8
Selected eigenvalue0.1522
Choose a family and size, then select an eigenvector with the slider or by clicking its point. The horizontal axis shows combinatorial Laplacian eigenvalues and stacks coincident values. Nodes are colored by the selected eigenvector; a repeated eigenspace admits many valid bases.

The figure’s regular graph adds a seeded perfect matching to a cycle: all degrees are 3, but this distribution is not uniform over regular graphs and a small sample does not establish asymptotic expansion. The grid is either 3×33\times3 or 4×44\times4, as indicated by the control.

Algebraic connectivity and Fiedler

The algebraic connectivity of an undirected graph is the second eigenvalue λ2(L)\lambda_2(\mat{L}), ordered from smallest to largest. By Courant-Fischer, for n≥2n\ge2,

λ2(L)=min⁡x≠0, x⊤1=0x⊤Lxx⊤x.\lambda_2(\mat{L})=\min_{\vb{x}\ne0,\ \vb{x}\T\vb{1}=0}\frac{\vb{x}\T\mat{L}\vb{x}}{\vb{x}\T\vb{x}}.

The Laplacian kernel has one dimension per component. Thus λ2>0\lambda_2>0 if and only if the graph is connected. A Fiedler vector is an eigenvector associated with that eigenvalue; if it is repeated, there is no unique direction. For the connected graph in the first figure we use the normalized version: if Lsymu=λ2u\mat{L}_{\mathrm{sym}}\vb{u}=\lambda_2\vb{u}, the cut coordinates are fi=ui/dif_i=u_i/\sqrt{d_i}.

Adding an edge of weight w≥0w\ge0 between existing nodes adds w(ei−ej)(ei−ej)⊤w(\vb{e}_i-\vb{e}_j)(\vb{e}_i-\vb{e}_j)\T to L\mat{L}. Every Rayleigh quotient increases or stays equal, so λ2(L)\lambda_2(\mat{L}) cannot decrease. The statement requires the same nodes and does not directly carry over to the normalized operator, whose denominator also changes as degrees change. Doubling all weights doubles L\mat{L} and its eigenvalues but leaves the normalized operator unchanged.

Diameter also constrains connectivity. In a connected graph with nn nodes and diameter DD, choose a geodesic between two extreme nodes. For every signal orthogonal to the constant, energy controls the difference between those endpoints by Cauchy-Schwarz. Several bounds depend on assumptions and exact definitions; here recall that a family of long paths has λ2(Pn)∼π2/n2\lambda_2(P_n)\sim\pi^2/n^2, which tends to zero. Do not confuse this combinatorial rate with a mixing rate without specifying the chain.

For a simple connected unweighted graph, one specific bound is λ2(L)≥4/(nD)\lambda_2(\mat{L})\ge 4/(nD). To see it, take a zero-mean signal and let RR be its maximum minus minimum. A path of length at most DD between the extremes and Cauchy-Schwarz give R2≤D x⊤LxR^2\le D\,\vb{x}\T\mat{L}\vb{x}. Moreover ∥x∥2≤nR2/4\norm{\vb{x}}^2\le nR^2/4: all values lie in an interval of length RR, and the sum of squared deviations from their mean is no greater than the sum relative to the interval midpoint. Dividing and minimizing over signals orthogonal to the constant proves the bound. General weights require an additional assumption, such as a positive minimum weight.

Conductance and Cheeger

The volume of SS is vol⁡(S)=∑i∈Sdi\operatorname{vol}(S)=\sum_{i\in S}d_i and the cut weight w(S,Sˉ)w(S,\bar S) sums crossing edges. The conductance of a nontrivial cut is

ϕ(S)=w(S,Sˉ)min⁡(vol⁡(S),vol⁡(Sˉ)),ϕ(G)=min⁡∅≠S⊊Vϕ(S).\phi(S)=\frac{w(S,\bar S)}{\min(\operatorname{vol}(S),\operatorname{vol}(\bar S))},\qquad \phi(G)=\min_{\varnothing\ne S\subsetneq V}\phi(S).

Now use λ2\lambda_2 of Lsym\mat{L}_{\mathrm{sym}}. Cheeger’s inequality states

λ22≤ϕ(G)≤2λ2.\frac{\lambda_2}{2}\le\phi(G)\le\sqrt{2\lambda_2}.
Proof

For the left bound, fix a cut and f=1S−a1f=\vb{1}_S-a\vb{1}, with a=vol⁡(S)/vol⁡(V)a=\operatorname{vol}(S)/\operatorname{vol}(V). Then f⊤D1=0f\T\mat{D}\vb{1}=0 and the generalized quotient permits ff as a candidate. Its numerator f⊤Lff\T\mat{L}f is the cut weight, since the difference across the cut is 1. Its denominator is vol⁡(S)vol⁡(Sˉ)/vol⁡(V)\operatorname{vol}(S)\operatorname{vol}(\bar S)/\operatorname{vol}(V). Therefore

λ2≤w(S,Sˉ)(1vol⁡(S)+1vol⁡(Sˉ))≤2ϕ(S).\lambda_2\le w(S,\bar S)\left(\frac1{\operatorname{vol}(S)}+\frac1{\operatorname{vol}(\bar S)}\right)\le2\phi(S).

Taking the minimum over cuts gives λ2/2≤ϕ(G)\lambda_2/2\le\phi(G).

∎

The harder direction is constructive. Sort fi=ui/dif_i=u_i/\sqrt{d_i} and evaluate all prefixes: this is the sweep cut. To sketch the proof, shift ff by a degree-weighted median and separate its positive and negative parts. One of them, call it g≥0g\ge0, has support of at most half the volume and Rayleigh quotient at most λ2\lambda_2: shifting by a constant leaves the numerator unchanged, weighted orthogonality ensures it does not reduce the denominator, and the energies of the two truncated parts sum to at most the original energy.

For thresholds of g2g^2, integrating cut weight counts each edge with factor ∣gi2−gj2∣|g_i^2-g_j^2|; integrating volume counts ∑idigi2\sum_i d_i g_i^2. Cauchy-Schwarz and (gi+gj)2≤2(gi2+gj2)(g_i+g_j)^2\le2(g_i^2+g_j^2) bound the ratio of those integrals by 2λ2\sqrt{2\lambda_2}. Some threshold achieves at least that quality. Its sets are prefixes or complements of prefixes in the ordering of ff, so the best sweep satisfies the upper bound. A detailed proof appears in Spielman’s notes.

InteractiveCheeger sweep
Order: [6] · 7 · 8 · 5 · 1 · 2 · 3 · 4. Brackets mark the current set.
01prefix size, 1 to 7
  • Conductance
  • λ₂ / 2
  • √(2λ₂)
1.0
1
Prefix φ1.000
Sweep minimum0.077
Lower bound0.057
Upper bound0.476
Advance through prefixes of the normalized random-walk vector and compare conductance with both bounds. To stabilize numerical ties, the figure sorts coordinates rounded to 1e-9 and breaks ties by index. The lower bound applies to all cuts; the upper bound guarantees that a prefix of the exact sweep attains it.

A sign cut uses only one threshold and may be worse than the best prefix. The complete ordering also avoids attaching significance to an eigenvector’s global sign: changing it reverses the order, and complementary cuts have the same conductance.

In the lab’s initial graph, each of the two cliques has volume 13: twelve units of internal degree and one from the bridge. Separating them cuts a single edge, so the conductance of that cut is 1/13≈0.0769231/13\approx0.076923. Execution returns λ2≈0.113382\lambda_2\approx0.113382, lower bound 0.0566910.056691 and upper bound 0.4761980.476198. The inequality guarantees an interval; it does not promise tight bounds or that the sweep solves the global minimum. The lab also compares against every cut in 200 small realizations to show that distinction.

Expansion and mixing

A family of expander graphs with bounded degree and growing size keeps conductance bounded away from zero. By Cheeger, a uniformly positive normalized gap λ2\lambda_2 is equivalent to that property for this purpose. There are no large-volume bottlenecks with negligible cut weight. For a lazy walk with matrix (I+P)/2(\mat{I}+\mat{P})/2, the gap controls relaxation; laziness avoids periodicity in bipartite graphs. Citing λ2\lambda_2 of the combinatorial Laplacian alone is insufficient to give a mixing rate without degrees and a time convention.

For dd-regular graphs, adjacency eigenvalues satisfy d=μ1≥μ2≥⋯d=\mu_1\ge\mu_2\ge\cdots and λ2(L)=d−μ2\lambda_2(\mat{L})=d-\mu_2. For a sequence of dd-regular graphs of growing size and fixed dd, the Alon-Boppana bound states that the lower limit of μ2\mu_2 is at least 2d−12\sqrt{d-1}. It is asymptotic rather than an exact inequality for each finite graph. Random regular graphs are useful for studying expansion; one sample does not establish that property for the entire sequence.

Lab: incremental sweep

The following function receives each undirected edge once. It sorts nodes in O(nlog⁡n)O(n\log n) and updates the cut when adding uu: each edge to a node already inside stops crossing, while each edge to the outside starts crossing. Overall, scanning neighbor lists costs O(m)O(m).

[ ]Sweep from scratchBrowser
import numpy as np
import networkx as nx
from scipy import sparse
from scipy.sparse.linalg import eigsh

def sweep_cut(n, edges, f):
    neighbors = [[] for _ in range(n)]
    for u,v,w in edges:
        neighbors[u].append((v,w)); neighbors[v].append((u,w))
    degree = np.array([sum(w for _,w in ns) for ns in neighbors])
    order = sorted(range(n), key=lambda i: (f[i],i))
    inside = np.zeros(n, dtype=bool)
    cut = volume = 0.0
    total = degree.sum()
    results = []
    for u in order[:-1]:
        cut += degree[u] - 2*sum(w for v,w in neighbors[u] if inside[v])
        volume += degree[u]
        inside[u] = True
        results.append(cut / min(volume,total-volume))
    best = int(np.argmin(results))
    return order[:best+1], results

def normalized_matrix(n, edges):
    A = np.zeros((n,n))
    for u,v,w in edges:
        A[u,v] += w; A[v,u] += w
    d = A.sum(axis=1)
    assert np.all(d > 0)
    R = np.diag(1/np.sqrt(d))
    return R @ (np.diag(d)-A) @ R, d

edges = [(i,j,1.0) for off in (0,4) for i in range(off,off+4) for j in range(i+1,off+4)] + [(0,4,1.0)]
M,d = normalized_matrix(8,edges)
vals, U = np.linalg.eigh(M)
lam = vals[1]
cut, phi = sweep_cut(8,edges,U[:,1]/np.sqrt(d))
print('λ₂:', round(lam,6), 'mejor corte:', cut, 'conductancia:', round(min(phi),6))
print('cotas:', round(lam/2,6), round(np.sqrt(2*lam),6))
assert lam/2 <= min(phi)+1e-10 and min(phi) <= np.sqrt(2*lam)+1e-10

Deflated power iteration operates on I−Lsym/2\mat{I}-\mat{L}_{\mathrm{sym}}/2, whose eigenvalues lie in [0,1][0,1]. Project out the trivial direction d\sqrt{\vb d} at each step. Compare with eigsh using a negative shift close to zero: an exactly zero shift makes the solve matrix singular. In large problems convergence depends on the gap and requires monitoring residuals.

[ ]Deflated power iteration and eigshBrowser
trivial = np.sqrt(d); trivial /= np.linalg.norm(trivial)
v = np.random.default_rng(5).normal(size=8)
T = np.eye(8)-M/2
for _ in range(600):
    v = T @ v
    v -= trivial * (trivial @ v)
    v /= np.linalg.norm(v)
estimate = v @ M @ v
small = np.sort(eigsh(sparse.csr_matrix(M), k=2, sigma=-1e-6, which='LM', return_eigenvectors=False))
residual = np.linalg.norm(M @ v - estimate*v)
print('potencia:', round(estimate,8), 'eigsh:', round(small[1],8), 'residuo:', round(residual,10))
assert abs(estimate-small[1]) < 1e-6 and residual < 1e-5

The NetworkX function algebraic_connectivity returns the second combinatorial eigenvalue, so compare it with L\mat{L} rather than the normalized value above.

[ ]Comparison with NetworkXBrowser
G_example = nx.Graph()
G_example.add_weighted_edges_from(edges)
A_example = nx.to_numpy_array(G_example, nodelist=range(8), weight='weight')
L_example = np.diag(A_example.sum(axis=1)) - A_example
direct = np.linalg.eigvalsh(L_example)[1]
library = nx.algebraic_connectivity(G_example, weight='weight', method='lanczos')
print('λ₂ combinatorio, matriz y NetworkX:', round(direct,8), round(library,8))
assert np.isclose(direct,library,atol=1e-8)

To check the lower bound we need actual minimum conductance, not just the best prefix. With eight nodes we can enumerate cuts. Repeat the next cell for 200 realizations from four generators; seeds and sizes are specified in the code. This tests the implementation on these finite cases and does not prove the theorem.

[ ]Exhaustive check of small cutsBrowser
def exact_phi(n, edges, degree):
    total = degree.sum(); best = float('inf')
    for mask in range(1, (1<<n)-1):
        vol = sum(degree[i] for i in range(n) if mask & (1<<i))
        cut = sum(w for u,v,w in edges if bool(mask & (1<<u)) != bool(mask & (1<<v)))
        best = min(best, cut/min(vol,total-vol))
    return best

def trial(i):
    family = i % 4
    seed = i
    while True:
        if family == 0: G = nx.fast_gnp_random_graph(8, 0.45, seed=seed)
        elif family == 1: G = nx.random_regular_graph(3, 8, seed=seed)
        elif family == 2: G = nx.watts_strogatz_graph(8, 4, 0.3, seed=seed)
        else: G = nx.random_labeled_tree(8, seed=seed)
        if nx.is_connected(G): break
        seed += 1000
    e = [(u,v,1.0) for u,v in G.edges]
    M,d = normalized_matrix(8,e)
    eig,U = np.linalg.eigh(M)
    _, curve = sweep_cut(8,e,U[:,1]/np.sqrt(d))
    exact = exact_phi(8,e,d)
    assert eig[1]/2 <= exact + 1e-9
    assert exact <= min(curve) + 1e-9
    assert min(curve) <= np.sqrt(2*eig[1]) + 1e-9
    return min(curve)-exact
[ ]First fifty realizationsBrowser
gaps = [trial(i) for i in range(50)]
print('comprobadas:', len(gaps), 'máxima diferencia barrido-exacto:', round(max(gaps),6))
[ ]Fifty more realizationsBrowser
gaps += [trial(i) for i in range(50,100)]
print('comprobadas:', len(gaps), 'máxima diferencia barrido-exacto:', round(max(gaps),6))
[ ]Up to one hundred and fiftyBrowser
gaps += [trial(i) for i in range(100,150)]
print('comprobadas:', len(gaps), 'máxima diferencia barrido-exacto:', round(max(gaps),6))
[ ]Two hundred realizationsBrowser
gaps += [trial(i) for i in range(150,200)]
print('comprobadas:', len(gaps), 'máxima diferencia barrido-exacto:', round(max(gaps),6))

In this execution the largest difference between the sweep cut and the exhaustive optimum was 0.166667. That difference shows why an approximation guarantee does not make the sweep an exact algorithm.

Lab: regular versus geometric

Fix 48 nodes and 96 edges, giving mean degree 4. In the regular graph each degree is 4; in the geometric graph points are sampled uniformly in a square and the 96 closest pairs are selected, equivalent to choosing a radius afterward between distances 96 and 97. Matching mean degree does not match degree distributions. Calculate the largest component’s diameter and report its size. The sweep is not exact minimum conductance: it supplies one particular cut.

[ ]Same number of edges, different geometriesBrowser
from scipy.sparse.csgraph import laplacian as cs_laplacian

def geometric_fixed_edges(n,m,seed):
    points = np.random.default_rng(seed).random((n,2))
    pairs = sorted((float(np.linalg.norm(points[i]-points[j])),i,j)
                   for i in range(n) for j in range(i+1,n))
    G=nx.Graph(); G.add_nodes_from(range(n))
    G.add_edges_from((i,j) for _,i,j in pairs[:m])
    return G

def summary(G):
    A=nx.to_numpy_array(G,nodelist=range(len(G)))
    Lsym=cs_laplacian(A,normed=True)
    vals,U=np.linalg.eigh(Lsym)
    d=A.sum(axis=1)
    component=max(nx.connected_components(G),key=len)
    phi=None
    if nx.is_connected(G):
        e=[(u,v,1.0) for u,v in G.edges]
        _, curve=sweep_cut(len(G),e,U[:,1]/np.sqrt(d))
        phi=round(min(curve),4)
    return {'aristas':G.number_of_edges(), 'componente':len(component),
            'diámetro componente':nx.diameter(G.subgraph(component)),
            'λ₂ normalizado':round(max(0.0,vals[1]),4), 'barrido':phi}

regular=nx.random_regular_graph(4,48,seed=21)
geometric=geometric_fixed_edges(48,96,21)
print('regular:',summary(regular))
print('geométrico:',summary(geometric))
mu2=np.linalg.eigvalsh(nx.to_numpy_array(regular))[-2]
print('μ₂ regular:',round(mu2,4),'referencia asintótica:',round(2*np.sqrt(3),4))
assert regular.number_of_edges()==geometric.number_of_edges()==96

The comparison describes these two realizations. Conclusions about distributions require repeating seeds and sizes; Alon-Boppana bounds the behavior of a sequence and does not require the sample eigenvalue to exceed its reference value.

In the execution with seed 21, the regular graph has a largest component of 48 nodes, diameter 5, normalized gap approximately 0.1699 and sweep-cut conductance 0.1875. The geometric graph has a largest component of 41 nodes, diameter 12 within that component and a zero second normalized eigenvalue because it is disconnected; no Fiedler sweep is reported as though unique. The regular graph’s μ2≈3.3204\mu_2\approx3.3204 is below 23≈3.46412\sqrt3\approx3.4641 without contradicting Alon-Boppana, precisely because this is one finite graph.

Exercises

Proof
Prove: On C_n, Fourier mode k has eigenvalue 2 - 2 cos(2πk/n).
0
Node indices are taken modulo n, with n at least 3.

Step 1 of 2. How are the neighbors related to mode u_j?

Proof
Prove: For a connected graph, λ₂/2 is no greater than minimum conductance.
0
For a cut S, center its indicator with the degree-weighted mean.

Step 1 of 2. Why is this vector admissible for the generalized quotient?

Numeric
Calculate λ₂ of the combinatorial Laplacian of path P_100. Give a decimal answer.
Numeric
For lazy walks on P_100 and C_100, how many times larger is the path's spectral relaxation time? Use the ratio of inverse gaps and the formulas 1 - cos(π/99) for the path and 1 - cos(2π/100) for the cycle before introducing laziness.
Quiz
In a connected graph, which statement is always true for λ₂ of the combinatorial Laplacian?
Code
Implement sweep_cut(edge_index, x), returning the nodes in the minimum-conductance prefix, ordered by (x[i], i). edge_index contains both directions of a simple connected undirected graph without self-loops; x has n entries, with n ≥ 2. On a tie, return the first prefix. Sort once and update cut and volume by visiting neighbors without enumerating every cut.
def sweep_cut(edge_index, x):
  pass
Shift+Enter to run

Key ideas

Key idea
The second mode turns a discrete cut problem into a continuous ordering. The sweep recovers a cut with a guarantee expressed in terms of the normalized gap.

Explicit spectra help us understand and check algorithms. A positive gap in a bounded-degree family controls expansion and, for lazy walks, relaxation toward equilibrium.