For a similarity graph with symmetric non-negative weights W and degree matrix D, let L=D−W. How do you prove that f⊤Lf=12∑i,jwij(fi−fj)2, how does this show that the number of zero eigenvalues of L equals the number of connected components, and why does this justify spectral clustering?

Unsupervised learning, Clustering
Level L4 Advanced. Length Medium. Nature Mat Mathematical.

What's being asked

Whether you can expand the quadratic form and turn it into a statement about which vectors L sends to zero.

Key idea

wij≥0 is the similarity between points i and j, and D is diagonal with di=∑jwij. Since f⊤Lf=12∑i,jwij(fi−fj)2≥0, L is positive semidefinite, and Lf=0 exactly when fi=fj for every connected pair, i.e. when f is constant on each connected component. So the vectors with Lf=0 are spanned by the component indicator vectors 1A1,…,1Ak, where 1A is 1 on the points of component A and 0 elsewhere.

Steps

  1. Expand: f⊤Lf=f⊤Df−f⊤Wf=∑idifi2−∑i,jwijfifj. By symmetry of W, ∑idifi2=12∑i,jwij(fi2+fj2). So f⊤Lf=12∑i,jwij(fi2−2fifj+fj2)=12∑i,jwij(fi−fj)2.
  2. Draw the consequences: L is symmetric and positive semidefinite (PSD: f⊤Lf≥0 for every f), so its eigenvalues are ≥0. Also L1=0, since each row of L sums to di−∑jwij=0.
  3. For a PSD matrix, Lf=0 exactly when f⊤Lf=0. The sum of non-negative terms is zero only if fi=fj for every pair with wij>0. Following paths of such pairs, f must be constant within each connected component, though it can differ between components.
  4. Count: the vectors with Lf=0 are exactly the combinations of 1A1,…,1Ak. These are non-zero and do not overlap, so they are linearly independent. Hence the eigenvalue 0 appears exactly k times.
  5. Link to spectral clustering. Put the eigenvectors for the k smallest eigenvalues as columns of U∈Rn×k and run k-means on the rows of U. With k separate components, all rows in one component are identical and rows from different components differ, so k-means recovers the components exactly. With weak links between clusters, the rows stay close to this ideal picture.
  6. Give an example: two concentric rings, joined into a graph by connecting points closer than ε (smaller than the gap between the rings), form two components. Spectral clustering separates them, although k-means on the raw coordinates cannot.

Common mistakes

How long your answer should be

Half a page of proof plus 2–3 sentences; about 5 minutes.

Last checked on 4 December 2026.

Read this

Previous in Unsupervised learning: A linear autoencoder with a k-dimensional bottleneck, encoder W1∈Rk×d and decoder W2∈Rd×k, is trained with squared reconstruction error on centred data. How does its solution relate to PCA, and what changes with a nonlinear autoencoder?
Next in Unsupervised learning: In locally linear embedding (LLE), the weights wj reconstruct a point x from its neighbours ηj by minimising ∥x−∑jwjηj∥2 subject to ∑jwj=1. (a) Derive the closed-form weights using the local Gram matrix. (b) For x=(0,0) with neighbours η1=(1,0) and η2=(0,2), compute the weights. (c) What is the second stage of LLE, and why is regularisation needed when k>d?