Quant Memo
Advanced

The Graph Laplacian and Spectral Clustering

A matrix built from a network's connections whose eigenvectors reveal natural clusters — used to group assets by how tightly they co-move without assuming clusters are round or evenly sized.

Prerequisites: Eigenvalues & Eigenvectors, Quadratic Forms

Grouping stocks into clusters by how similarly they behave — sector-like groupings discovered from the data itself, not from an official sector label — is hard for standard clustering methods when the natural groups aren't neat round blobs but instead form chains, rings, or oddly shaped clusters in similarity space. K-means and similar methods struggle here because they assume clusters look like circles around a center. The graph Laplacian sidesteps that assumption entirely, turning clustering into an eigenvalue problem on a matrix built from pairwise similarities.

An analogy: a spring network settling into its natural groups

Imagine every pair of assets connected by a spring, whose stiffness is proportional to how correlated they are — tightly co-moving assets get a stiff spring, unrelated ones get a weak or absent spring. If you let this whole spring network vibrate, its natural, lowest-energy vibration patterns will tend to move tightly-connected clusters together as a block, with looser connections between blocks bending more easily. The graph Laplacian is the matrix that governs exactly this spring network's vibration, and its lowest eigenvectors are precisely those natural, cluster-revealing vibration patterns.

The math, one symbol at a time

Given a similarity (weighted adjacency) matrix WW where WijW_{ij} measures how strongly nodes ii and jj are connected, define the degree matrix DD (diagonal, with Dii=jWijD_{ii} = \sum_j W_{ij}, the total connection strength of node ii), and the graph Laplacian

L=DW.L = D - W.

In words: LL's diagonal holds each node's total connectivity, and its off-diagonal entries subtract off the specific pairwise strengths. The Laplacian's key property, via the quadratic form (see Quadratic Forms): xLx=12i,jWij(xixj)2x^\top L x = \frac{1}{2}\sum_{i,j} W_{ij}(x_i - x_j)^2 — a sum that's small exactly when strongly-connected nodes i,ji,j are assigned similar values xixjx_i \approx x_j. Spectral clustering finds the eigenvectors of LL with the smallest eigenvalues (excluding the trivial all-ones eigenvector with eigenvalue 0) and uses their entries as coordinates to cluster nodes — nodes that the low-energy eigenvectors treat similarly end up grouped together.

Worked example 1: two tightly connected pairs, weakly linked

Four assets: 1–2 strongly correlated (weight 5), 3–4 strongly correlated (weight 5), and only a weak link 2–3 (weight 0.1). D=diag(5,5.1,5.1,5)D = \text{diag}(5, 5.1, 5.1, 5), and L=DWL = D - W has this near-block structure. Its eigenvalues come out approximately 0,0.1,5,100, 0.1, 5, 10 — the second-smallest eigenvalue (0.1, not counting the trivial 0) is tiny precisely because the graph is almost two disconnected pieces joined by one weak link; the corresponding eigenvector takes one sign on nodes {1,2} and the opposite sign on {3,4}, directly revealing the two clusters by the sign pattern alone.

Worked example 2: reading off clusters from eigenvector signs

Continuing the example, the second-smallest eigenvector might come out approximately (0.5,0.49,0.49,0.5)(0.5, 0.49, -0.49, -0.5). Thresholding at zero: nodes 1 and 2 (positive) form one cluster, nodes 3 and 4 (negative) form the other — recovering exactly the intended grouping, using nothing but an eigenvector, with no assumption that clusters are round or evenly sized. If a third, genuinely separate cluster existed, the third-smallest eigenvector would typically reveal it, which is why spectral clustering with kk clusters generally uses the kk smallest nontrivial eigenvectors together as coordinates, then runs a simple clustering step (like k-means) on those coordinates instead of on the raw data.

1 2 3 4 weak link (0.1)
Thick edges are strong connections within a cluster; the thin dashed edge is the weak cross-cluster link the Laplacian's second-smallest eigenvector detects and cuts.
0 node 1: +0.5 node 2: +0.49 node 3: -0.49 node 4: -0.5
The second-smallest eigenvector's sign pattern directly separates the graph into its two natural clusters, positive versus negative entries.

What this means in practice

Spectral clustering via the graph Laplacian is used to discover data-driven groupings of assets from a correlation or similarity network — clusters that don't need to be predefined by industry classification and can capture co-movement patterns that cut across official sectors. It's related to hierarchical clustering methods used in portfolio construction (see Nested Clustered Optimization) and, more broadly, to any method that treats a correlation matrix as a graph rather than just a table of numbers.

The graph Laplacian L=DWL = D - W turns clustering into an eigenvalue problem: its smallest nontrivial eigenvectors assign similar values to strongly-connected nodes, and thresholding those values directly reveals natural clusters, even ones with irregular shapes that distance-based clustering methods miss.

Spectral clustering requires choosing how many eigenvectors (equivalently, how many clusters) to use, and this choice isn't automatic — picking too few merges genuinely distinct clusters, too many splits a real cluster apart. A common mistake is trusting the eigenvector sign pattern blindly without checking the eigenvalue gap: a small gap between the kk-th and (k+1)(k+1)-th smallest eigenvalues signals that the "kk clusters" structure is not sharply defined in the data, and the resulting groups should be treated as tentative rather than a firm ground truth.

Related concepts

Practice in interviews

Further reading

  • Von Luxburg (2007), A Tutorial on Spectral Clustering
ShareTwitterLinkedIn