Spectral Clustering
Not all learning runs on feature vectors. Often the data is a graph: nodes joined by weighted edges that record similarity, and the task is to split the nodes into clusters that are densely connected inside and sparsely connected across. Spectral clustering solves a relaxation of this combinatorial problem with linear algebra alone. It builds one symmetric matrix from the graph, the Laplacian, and reads the partition off its eigenvector for the second-smallest eigenvalue. The method ties together positive definiteness, the eigenvectors of a symmetric matrix, and the Rayleigh quotient.
The graph Laplacian
Section titled “The graph Laplacian”Let have nodes and a symmetric weight matrix with and , where measures the similarity between nodes and . The degree of node is .
The Laplacian’s value comes from the quadratic form it defines, which measures how much a function on the nodes varies across edges.
The quadratic form is a sum of penalties , one per edge: it is small exactly when takes nearly equal values on strongly connected nodes. This is why the Laplacian detects cluster structure.
Connected components live in the nullspace
Section titled “Connected components live in the nullspace”The values of that make the form vanish are precisely the functions constant on each piece of the graph.
A graph in one piece therefore has simple, and the next eigenvalue is the algebraic connectivity. When the graph is one piece but nearly splits into two, is small and its eigenvector is close to a step function that is constant on each near-component: the signal that there is a good cut to make.
From balanced cuts to the Fiedler vector
Section titled “From balanced cuts to the Fiedler vector”To split the nodes into two groups and its complement, count the weight crossing the boundary, the cut . Minimizing the cut alone tends to peel off a single node, so the cut is balanced by the group sizes. The ratio cut objective encodes both the boundary weight and the balance, and minimizing it over all partitions is NP-hard. Relaxing the discrete membership to a real vector turns it into an eigenvalue problem.
The relaxed solution is a real vector, so it is turned back into a partition by its sign: nodes with go to one cluster, the rest to the other. This recovers the intuition from the near-disconnected case, where already looks like the indicator of the split.
Cutting a graph
Section titled “Cutting a graph”The widget builds the Laplacian of a small graph, computes its Fiedler vector, and colors each node by the sign of that vector. Edges crossing the resulting partition are highlighted: they are the cut, and the relaxation chooses the split that keeps their total weight small relative to the group sizes.
Spectral clustering is the eigenvector face of cutting a graph. The combinatorial problem is hard, but its continuous relaxation is exactly a Rayleigh-quotient minimization, and the second eigenvector of the Laplacian carries the partition.