Skip to main content

Module communities

Module communities 

Source
Available on crate feature communities only.
Expand description

Spectral community detection ported from xgi/communities/spectral.py.

spectral_clustering builds the normalized hypergraph Laplacian (formula from the Phase-3 linalg/laplacian_matrix.py, inlined here for self-containment), extracts the k smallest-eigenvalue eigenvectors via hand-rolled power iteration + Hotelling deflation (the dependency probe found no LAPACK-free ndarray eigensolver), and runs Forgy k-means. Exact XGI parity is impossible (RNG divergence, spec §9.4); assertions are structural, and results are deterministic under a fixed seed.

Enums§

SpectralError
Errors raised by spectral clustering.

Functions§

kmeans
Forgy-initialized k-means over the rows of x.
normalized_laplacian
The dense normalized hypergraph Laplacian and its row→node-id map.
smallest_k_eigenvectors
The k smallest-eigenvalue eigenvectors of the symmetric matrix l, as columns.
spectral_clustering
Spectral clustering of a hypergraph into k partitions.