graphclust.validity.eigengap#

graphclust.validity.eigengap(affinity, max_clusters=10)[source]#

Number of clusters suggested by the spectrum of a graph, and the eigenvalues.

With \(\lambda_l\) the eigenvalues of \(\mathbf{D}^{-1/2}\mathbf{A}\mathbf{D}^{-1/2}\) in decreasing order and \(\mu_l=1-\lambda_l\) those of the normalized Laplacian, \(c\) clusters with few links between them give \(c\) eigenvalues \(\mu\) near zero followed by a jump. The function returns the \(c\ge2\) with the largest ratio \(\mu_{c+1}/\mu_c\) (a relative gap, robust to the slow decay of the remaining spectrum).