How is the eigengap heuristic used to determine the number of clusters in spectral clustering?

Last updated 11 November 2026

  • Sort Laplacian eigenvalues ascending and pick k where the gap λ_{k+1} − λ_k is largest (e.g. np.argmax(np.diff(eigvals)) + 1).

  • Rationale: k well-separated clusters give k near-zero eigenvalues well below λ_{k+1}. A larger gap also means a more stable eigenvector embedding (Davis-Kahan).

  • It fails with noisy or overlapping clusters and is sensitive to graph construction (σ, kNN k). Cross-check with stability or silhouette analysis.

  • https://www.youtube.com/watch?v=2DqTOsNlnak
  • https://medium.com/@guava1427/optimal-number-of-clusters-for-spectral-clustering-67037cf8a348
  • https://daily.dev/posts/spectral-clustering-explained-how-eigenvectors-reveal-complex-cluster-structures-bpoklwbz9
All Clustering interview questions