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.
Metadata
Release files for louvain-numba 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| louvain-numba-0.0.2.tar.gz | 7.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| louvain_numba-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.2 kB
Release files / louvain-numba-0.0.2.tar.gz
| Download URL | louvain-numba-0.0.2.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f9425e82f6379839ed51c4ce1dbd6bd5467368a6c9779bb59a97472a0f51099a
|
|
BLAKE2b-256 checksum How to use checksums |
65cd53fd83f2bda123fc646b3509a1a84e8a38dbaec3a994c58eabeacca6390e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.12 CPython/3.10.12 Linux/6.5.0-41-generic
|
Release files / louvain_numba-0.0.2-py3-none-any.whl
| Download URL | louvain_numba-0.0.2-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5954006dd49921f7293b9f1a4356f943f3315d3f1e27d6c34fdbbc87efaed311
|
|
BLAKE2b-256 checksum How to use checksums |
2ce5f3eeaf09c9127161ba8e3995e6569af70daeb372cc13a788d1a71be7cdd6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.12 CPython/3.10.12 Linux/6.5.0-41-generic
|