graphclust: graph-based clustering and data visualization in Python
graphclust is a scikit-learn compatible toolbox for clustering and visualizing data through graphs: neighborhood graphs and geodesic distances, topology learning with neural gas and topology representing networks, clustering with spanning trees, shared neighbors and communities, and maps of high-dimensional data from Sammon's mapping to TRNMap and UMAP. It is the Python successor of the MATLAB toolbox that accompanied the monograph Graph-Based Clustering and Data Visualization Algorithms (Á. Vathy-Fogarassy, J. Abonyi, SpringerBriefs in Computer Science, 2013), extended with the main graph-based methods published since then.
| Module | Contents |
|---|---|
graphclust.graphs |
kNN, mutual kNN, ε, nearest neighbor, MST, relative neighborhood, Gabriel and Delaunay graphs; competitive Hebbian (induced Delaunay) graph; shared-neighbor counts; geodesic distances |
graphclust.vq |
LBG, neural gas, topology representing network, growing neural gas, grow when required, dynamic TRN, weighted incremental network |
graphclust.cluster |
Zahn's MST clustering, hybrid MST–Gath–Geva, HDBSCAN*, Jarvis–Patrick, fuzzy neighborhood similarity, SNN density clustering, density peaks, self-tuning spectral clustering, Louvain/Leiden communities |
graphclust.validity |
Dunn index with MST diameters, Fukuyama–Sugeno, fuzzy hypervolume, DBCV, eigengap, clustering rate |
graphclust.vat |
VAT and iVAT images |
graphclust.manifold |
classical/metric/non-metric MDS, Sammon, LPP, SOM, incremental grid growing, Isomap, Isotop, CCA/CDA, OVI-NG, GNLP-NG, TRNMap, Laplacian eigenmaps, diffusion maps, UMAP, t-SNE |
graphclust.metrics |
Sammon and MDS stress, residual variance, trustworthiness, continuity, co-ranking matrix, Q_NX, R_NX, LCMC, AUC, topographic error and product |
graphclust.datasets, plotting |
Variety, ChainLink, Curves, Boxlinecircle and manifold generators; plotting helpers |
Installation
pip install graphclust # numpy, scipy, scikit-learn, networkx, matplotlib
pip install "graphclust[leiden]" # optional Leiden community detection
Quick start
from graphclust import TRNMap, HybridMSTGG, HDBSCANStar, fuzzy_neighborhood_similarity
from graphclust.datasets import make_s_curve, make_chainlink
from graphclust.metrics import trustworthiness_continuity
# map a curved manifold with the topology representing network map
X, t = make_s_curve(2000, random_state=0)
tm = TRNMap(n_nodes=150, random_state=0).fit(X)
tm.nodes_, tm.adjacency_, tm.embedding_
print(trustworthiness_continuity(tm.dist_matrix_, tm.embedding_, 5, precomputed=True))
# cluster groups joined by a chain
Xc, yc = make_chainlink()
hyb = HybridMSTGG(max_clusters=4, lambda_=2.5).fit(Xc)
hyb.labels_, hyb.membership_, hyb.covariances_
HDBSCANStar(min_cluster_size=8).fit(Xc).labels_
# shared-neighbor similarity for hierarchical clustering, MDS or VAT
S = fuzzy_neighborhood_similarity(Xc, k=6, r_max=3, alpha=0.2)
The book
Graph-Based Clustering and Data Visualization in Python: The graphclust toolbox (Á. Vathy-Fogarassy, J. Abonyi) develops every method in one notation and illustrates it with the scripts of the example gallery. It is available as a web edition, PDF and EPUB under CC BY 4.0. The book is a new text: it re-derives and re-implements the methods of the 2013 monograph and adds HDBSCAN*, DBCV, density peaks, Louvain/Leiden communities, iVAT, the co-ranking framework, diffusion maps, t-SNE and UMAP.
Documentation
- Example gallery: 29 scripts, each runnable as a Jupyter notebook (Binder, Colab).
- API reference.
- Migration from the MATLAB toolbox.
Development
git clone https://github.com/ComplexSystemsIntelligence/graphclust.git
cd graphclust
pip install -e ".[dev]"
pytest # unit tests and doctests
book/build.sh # the book (TeX Live with raleway, plex, libertinus, biber)
sphinx-build -b html docs docs/_build/html
Citing
Please cite the package (see CITATION.cff) together with the original
publications of the methods you use; every docstring and every chapter of the
book lists them.
Acknowledgments
The research summarized in the package and the book was supported by the National Research, Development and Innovation Office of Hungary (NKFIH) through the OTKA 143482 project.
License
Software: MIT. Book: CC BY 4.0.
Metadata
Release files for graphclust 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| graphclust-1.0.tar.gz | 200.1 kB | With provenance | Details for graphclust-1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| graphclust-1.0-py3-none-any.whl | Python 3 | none | any | Details for graphclust-1.0-py3-none-any.whl |
Total release size: 382.2 kB
Release files / graphclust-1.0.tar.gz
| Download URL | graphclust-1.0.tar.gz |
|---|---|
| Size | 200.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
926c5d0f70b4d546d241ab00001953fad47dfd6541e91443e5b5e0acceb2af71
|
|
BLAKE2b-256 checksum How to use checksums |
ac33fe2a7536745f01b35e6fd9c0620f9adde8e54c312d9f1f95fc026bfd58e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logRelease files / graphclust-1.0-py3-none-any.whl
| Download URL | graphclust-1.0-py3-none-any.whl |
|---|---|
| Size | 182.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a3d99cf68607706d454963f3c08a7bb15c62d28709590c4ad6d31e049e19a545
|
|
BLAKE2b-256 checksum How to use checksums |
f1809356cb51195d47c593e0e79a4e9fa00bad0b8b3fc9dfee65a7e80abf1fc4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logSecurity for graphclust 1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for graphclust-1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.