Metadata-Version: 2.5
Name: graphclust
Version: 1.0
Summary: Graph-based clustering and data visualization: topology representing networks, MST and hybrid MST-Gath-Geva clustering, fuzzy neighborhood similarity, HDBSCAN*, TRNMap, Isotop, CDA, UMAP and mapping quality measures, scikit-learn compatible.
Project-URL: Homepage, https://github.com/ComplexSystemsIntelligence/graphclust
Project-URL: Documentation, https://complexsystemsintelligence.github.io/graphclust
Project-URL: Repository, https://github.com/ComplexSystemsIntelligence/graphclust
Project-URL: Issues, https://github.com/ComplexSystemsIntelligence/graphclust/issues
Project-URL: Changelog, https://github.com/ComplexSystemsIntelligence/graphclust/blob/main/CHANGELOG.md
Project-URL: Book (PDF), https://complexsystemsintelligence.github.io/graphclust/graphclust-book.pdf
Author: Ágnes Vathy-Fogarassy
Author-email: János Abonyi <janos@abonyilab.com>
License-Expression: MIT
License-File: LICENSE
Keywords: HDBSCAN,Isomap,Jarvis-Patrick,TRNMap,UMAP,dimensionality reduction,graph-based clustering,minimal spanning tree,neural gas,topology representing network,trustworthiness
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Visualization
Requires-Python: >=3.10
Requires-Dist: matplotlib>=3.7
Requires-Dist: networkx>=3.0
Requires-Dist: numpy>=1.24
Requires-Dist: scikit-learn>=1.3
Requires-Dist: scipy>=1.10
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: myst-parser; extra == 'dev'
Requires-Dist: numpydoc; extra == 'dev'
Requires-Dist: pydata-sphinx-theme; extra == 'dev'
Requires-Dist: pytest-cov; extra == 'dev'
Requires-Dist: pytest>=7; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Requires-Dist: sphinx-copybutton; extra == 'dev'
Requires-Dist: sphinx-design; extra == 'dev'
Requires-Dist: sphinx-gallery>=0.15; extra == 'dev'
Requires-Dist: sphinx>=7; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Provides-Extra: docs
Requires-Dist: myst-parser; extra == 'docs'
Requires-Dist: numpydoc; extra == 'docs'
Requires-Dist: pydata-sphinx-theme; extra == 'docs'
Requires-Dist: sphinx-copybutton; extra == 'docs'
Requires-Dist: sphinx-design; extra == 'docs'
Requires-Dist: sphinx-gallery>=0.15; extra == 'docs'
Requires-Dist: sphinx>=7; extra == 'docs'
Provides-Extra: leiden
Requires-Dist: igraph>=0.11; extra == 'leiden'
Requires-Dist: leidenalg>=0.10; extra == 'leiden'
Provides-Extra: test
Requires-Dist: pytest-cov; extra == 'test'
Requires-Dist: pytest>=7; extra == 'test'
Description-Content-Type: text/markdown

<p align="center"><img src="https://raw.githubusercontent.com/ComplexSystemsIntelligence/graphclust/main/docs/_static/banner.png" alt="graphclust: graph-based clustering and data visualization in Python"></p>

# graphclust: graph-based clustering and data visualization in Python

[![tests](https://github.com/ComplexSystemsIntelligence/graphclust/actions/workflows/ci.yml/badge.svg)](https://github.com/ComplexSystemsIntelligence/graphclust/actions/workflows/ci.yml)
[![docs](https://img.shields.io/badge/docs-gallery%20%2B%20API-285780)](https://complexsystemsintelligence.github.io/graphclust)
[![PyPI](https://img.shields.io/pypi/v/graphclust.svg)](https://pypi.org/project/graphclust/)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/ComplexSystemsIntelligence/graphclust/blob/main/LICENSE)

**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

```bash
pip install graphclust              # numpy, scipy, scikit-learn, networkx, matplotlib
pip install "graphclust[leiden]"    # optional Leiden community detection
```

## Quick start

```python
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](https://complexsystemsintelligence.github.io/graphclust/book/),
[PDF](https://complexsystemsintelligence.github.io/graphclust/graphclust-book.pdf)
and [EPUB](https://complexsystemsintelligence.github.io/graphclust/graphclust-book.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](https://complexsystemsintelligence.github.io/graphclust/auto_examples/index.html):
  29 scripts, each runnable as a Jupyter notebook (Binder, Colab).
* [API reference](https://complexsystemsintelligence.github.io/graphclust/api/index.html).
* [Migration from the MATLAB toolbox](https://complexsystemsintelligence.github.io/graphclust/migration.html).

## Development

```bash
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.
