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 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.
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 ; distinguishing it from 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 : for .
- Cycle , : for .
- Grid : all sums of an eigenvalue of and one of .
- Complete : 0 once and with multiplicity .
- Star , : 0 once, 1 with multiplicity and once.
On the cycle, discrete Fourier transform modes with indices diagonalize . The two neighbors contribute , so . 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 to .
The grid is a Cartesian product: its Laplacian is . On it acts as . For , : it annihilates the constant and multiplies any vector orthogonal to it by . The star was analyzed in the previous lesson.
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 or , as indicated by the control.
Algebraic connectivity and Fiedler
The algebraic connectivity of an undirected graph is the second eigenvalue , ordered from smallest to largest. By Courant-Fischer, for ,
The Laplacian kernel has one dimension per component. Thus 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 , the cut coordinates are .
Adding an edge of weight between existing nodes adds to . Every Rayleigh quotient increases or stays equal, so 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 and its eigenvalues but leaves the normalized operator unchanged.
Diameter also constrains connectivity. In a connected graph with nodes and diameter , 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 , 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 . To see it, take a zero-mean signal and let be its maximum minus minimum. A path of length at most between the extremes and Cauchy-Schwarz give . Moreover : all values lie in an interval of length , 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 is and the cut weight sums crossing edges. The conductance of a nontrivial cut is
Now use of . Cheeger’s inequality states
Proof
For the left bound, fix a cut and , with . Then and the generalized quotient permits as a candidate. Its numerator is the cut weight, since the difference across the cut is 1. Its denominator is . Therefore
Taking the minimum over cuts gives .
∎The harder direction is constructive. Sort and evaluate all prefixes: this is the sweep cut. To sketch the proof, shift by a degree-weighted median and separate its positive and negative parts. One of them, call it , has support of at most half the volume and Rayleigh quotient at most : 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 , integrating cut weight counts each edge with factor ; integrating volume counts . Cauchy-Schwarz and bound the ratio of those integrals by . Some threshold achieves at least that quality. Its sets are prefixes or complements of prefixes in the ordering of , so the best sweep satisfies the upper bound. A detailed proof appears in Spielman’s notes.
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 . Execution returns , lower bound and upper bound . 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 is equivalent to that property for this purpose. There are no large-volume bottlenecks with negligible cut weight. For a lazy walk with matrix , the gap controls relaxation; laziness avoids periodicity in bipartite graphs. Citing of the combinatorial Laplacian alone is insufficient to give a mixing rate without degrees and a time convention.
For -regular graphs, adjacency eigenvalues satisfy and . For a sequence of -regular graphs of growing size and fixed , the Alon-Boppana bound states that the lower limit of is at least . 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 and updates the cut when adding : each edge to a node already inside stops crossing, while each edge to the outside starts crossing. Overall, scanning neighbor lists costs .
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-10Deflated power iteration operates on , whose eigenvalues lie in . Project out the trivial direction 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.
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-5The NetworkX function algebraic_connectivity returns the second combinatorial eigenvalue, so compare it with rather than the normalized value above.
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.
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)-exactgaps = [trial(i) for i in range(50)]
print('comprobadas:', len(gaps), 'máxima diferencia barrido-exacto:', round(max(gaps),6))gaps += [trial(i) for i in range(50,100)]
print('comprobadas:', len(gaps), 'máxima diferencia barrido-exacto:', round(max(gaps),6))gaps += [trial(i) for i in range(100,150)]
print('comprobadas:', len(gaps), 'máxima diferencia barrido-exacto:', round(max(gaps),6))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.
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()==96The 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 is below without contradicting Alon-Boppana, precisely because this is one finite graph.
Exercises
Step 1 of 2. How are the neighbors related to mode u_j?
Step 1 of 2. Why is this vector admissible for the generalized quotient?
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):
passKey ideas
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.