Community detection via Louvain/Leiden + Genetic Algorithm
Project description
TAU: Parallel Genetic Clustering with Louvain and Leiden
TAU is a high-performance Python package for modularity-based community detection using a hybrid of genetic algorithms and graph clustering methods (Louvain and Leiden). It is built for scalability, parallelism, and usability across research and applied machine learning settings.
Features
- Genetic Initialization: Enhances clustering quality by optimizing initial conditions with evolutionary search.
- Pluggable Clustering Engines: Supports Louvain and Leiden algorithms.
- Parallel Execution: Uses Python's multiprocessing/threading for speed-up across CPUs.
- Flexible Graph Input: Read from adjacency lists, edge lists, CSVs, or pandas DataFrames.
- CLI and API Access: Run from the terminal or call programmatically in Python.
- Reproducible Runs: Optional random seed parameter for repeatable experiments.
Installation
From PyPI
pip install community_TAU
From Source
git clone https://github.com/HillelCharbit/community_TAU.git
cd community_TAU
pip install .
Quick Start
Command-Line Interface
python -m community_TAU --graph data/example.graph --size 80 --workers 4 --max_generations 300
Command-Line Arguments
| Argument | Description | Default |
|---|---|---|
--graph |
Path to graph file (adjacency list, edge list, etc.) | Required |
--size |
Population size for genetic algorithm | 60 |
--workers |
Number of parallel workers | All available cores |
--max_generations |
Maximum number of generations | 500 |
--seed |
Random seed (optional) | None |
Python API Example
from community_TAU import community_TAU
import networkx as nx
G = nx.read_edgelist("example.graph")
result = community_TAU(G, size=100, workers=8, max_generations=400)
# Access results
print(result.partition)
print(result.modularity)
Input Formats Supported
- Adjacency list (
.graph) - Edge list (
.csv,.txt) - Adjacency matrix (CSV or DataFrame)
Conversion tools are available in the graph_loader module.
Output
- Final partition (dictionary of node → community)
- Final modularity score
- Optional generation logs and fitness history
Testing
To run unit tests:
pytest tests/
Test coverage includes input parsing, genetic algorithm logic, clustering evaluation, and parallel execution.
Contributing
We welcome contributions! To get started:
- Fork this repository
- Create a feature branch (
git checkout -b feature/my-feature) - Make your changes and commit (
git commit -am 'Add new feature') - Push to the branch (
git push origin feature/my-feature) - Open a pull request
Please review the contributing guidelines before submitting changes.
License
This project is licensed under the MIT License.
Acknowledgments
- Louvain and Leiden algorithms based on work by Blondel et al. and Traag et al.
- Graph handling inspired by NetworkX and igraph interfaces.
Project Status
TAU is actively maintained and under continuous development. Feedback and issues are welcome on the GitHub issue tracker.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tau_community_detection-0.3.14.tar.gz.
File metadata
- Download URL: tau_community_detection-0.3.14.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06b4a4e4574ea52401bc3d3a1943d1b799212c38f4d83c8085e2d088c564e5fd
|
|
| MD5 |
69067c478f6e35186c95b487387267dd
|
|
| BLAKE2b-256 |
86fe66f4b4492010b0ecb43c26b290dc89c6dc7d2e1ae67723af5351944064a3
|
File details
Details for the file tau_community_detection-0.3.14-py3-none-any.whl.
File metadata
- Download URL: tau_community_detection-0.3.14-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7e12bba93f6881bce2bfcd2317fb2643ceead93fe187ef32988f4ca697eaf0c
|
|
| MD5 |
be277e365ad1dde3d38e1f2c92838e14
|
|
| BLAKE2b-256 |
3ba4ab58a696fa97500eda614049d1e94f4ebeeb75879a8576f7af00f7b187a0
|