Skip to main content

A package for fast community detection in graphs using the Louvain method with Numba optimization.

Project description

Louvain-Numba

Louvain-Numba is a Python library for community detection in graphs using the Louvain method with Numba optimization. This library leverages Numba to accelerate the community detection process, making it suitable for large-scale graphs.

Features

  • Efficient community detection using the Louvain method
  • Optimized with Numba for high performance
  • Supports various graph input types (NetworkX, NumPy arrays, SciPy sparse matrices)
  • Generates hierarchical community structures

Installation

You can install Louvain-Numba via pip:

pip install louvain-numba

Or using Poetry:

poetry add louvain-numba

Usage

Basic Usage

import networkx as nx
import louvain_numba as lvn

# Create a random graph
G = nx.random_partition_graph([100, 100, 100], 0.1, 0.01)

# Find the best partition
partition = lvn.best_partition(G)
print("Best partition:", partition)

# Calculate modularity
modularity = lvn.modularity(partition, G)
print("Modularity:", modularity)

Specify prefered number of clusters

import networkx as nx
import louvain_numba as lvn

# Create a random graph
G = nx.random_partition_graph([100, 100, 100], 0.1, 0.01)

# Find the best partition
partition = lvn.best_partition(G, n_clusters=(7, 10))
print("Best partition:", partition)

# Calculate modularity
modularity = lvn.modularity(partition, G)
print("Modularity:", modularity)

Full Hierarchy

import networkx as nx
import louvain_numba as lvn

# Create a random graph
G = nx.random_partition_graph([100, 100, 100], 0.1, 0.01)

# Generate full hierarchy of partitions
for level, (partition, modularity) in enumerate(lvn.find_partitions(G, return_modularity=True)):
    print(f"Level {level}:")
    print("Partition:", partition)
    print("Modularity:", modularity)

Contributing

Contributions are welcome! If you have any suggestions, bug reports, or feature requests, please open an issue or submit a pull request on GitHub. License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgements

This library was inspired by the cylouvain package and leverages Numba for performance optimization.

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

louvain-numba-0.0.2.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

louvain_numba-0.0.2-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file louvain-numba-0.0.2.tar.gz.

File metadata

  • Download URL: louvain-numba-0.0.2.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.12 Linux/6.5.0-41-generic

File hashes

Hashes for louvain-numba-0.0.2.tar.gz
Algorithm Hash digest
SHA256 f9425e82f6379839ed51c4ce1dbd6bd5467368a6c9779bb59a97472a0f51099a
MD5 ef2cbd66523ae59e9a3e5bd13af526dc
BLAKE2b-256 65cd53fd83f2bda123fc646b3509a1a84e8a38dbaec3a994c58eabeacca6390e

See more details on using hashes here.

File details

Details for the file louvain_numba-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: louvain_numba-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.12 Linux/6.5.0-41-generic

File hashes

Hashes for louvain_numba-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5954006dd49921f7293b9f1a4356f943f3315d3f1e27d6c34fdbbc87efaed311
MD5 e83cf4b88c163240b224f189e00702ca
BLAKE2b-256 2ce5f3eeaf09c9127161ba8e3995e6569af70daeb372cc13a788d1a71be7cdd6

See more details on using hashes here.

Supported by

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