Skip to main content

Community detection via Louvain/Leiden + Genetic Algorithm

Project description

TAU: Parallel Genetic Clustering with Louvain and Leiden

PyPI Build License: MIT Python 3.8+

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:

  1. Fork this repository
  2. Create a feature branch (git checkout -b feature/my-feature)
  3. Make your changes and commit (git commit -am 'Add new feature')
  4. Push to the branch (git push origin feature/my-feature)
  5. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tau_community_detection-0.3.13.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tau_community_detection-0.3.13-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file tau_community_detection-0.3.13.tar.gz.

File metadata

  • Download URL: tau_community_detection-0.3.13.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for tau_community_detection-0.3.13.tar.gz
Algorithm Hash digest
SHA256 d9f4fdf2bdae1a7366852c58e4b8bdf3b66211779cda61429bca30d9a45ed1bb
MD5 a622b4f17c34be0eca0bac6a899debc5
BLAKE2b-256 1357032ba89f725b34fb5530ac07e880750e6605320b4f692082ffc66a03e24b

See more details on using hashes here.

File details

Details for the file tau_community_detection-0.3.13-py3-none-any.whl.

File metadata

File hashes

Hashes for tau_community_detection-0.3.13-py3-none-any.whl
Algorithm Hash digest
SHA256 2f8d75a2b02c14e2aa402efb0024039eda1f3b09bf39c2722dd317cf3090a615
MD5 b7f581b57581fe1e84ba463b8e43f5c2
BLAKE2b-256 e6e1c9ee8d5caac8b015266901a89b6c8850e0f7b5999bd023a83e57e0580a06

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page