ModularityPruning
ModularityPruning is a pruning tool to identify small subsets of network partitions that are significant from the perspective of stochastic block model inference. This method works for single-layer and multi-layer networks, as well as for restricting focus to a fixed number of communities when desired.
See the documentation or the journal article at https://doi.org/10.1038/s41598-022-20142-6 for more information.
Significantly more details can be found in the article's Supplementary Information.
Installation
This project is on PyPI and can be installed with
pip install modularitypruning
# OR
pip3 install modularitypruning
Alternatively, you can install it from this repository directly:
git clone https://github.com/ragibson/ModularityPruning
cd ModularityPruning
python3 setup.py install
Basic Usage
This package interfaces directly with python-igraph. A simple example of its usage is
import igraph as ig
from modularitypruning import prune_to_stable_partitions
from modularitypruning.leiden_utilities import repeated_leiden_from_gammas
import numpy as np
# get Karate Club graph in igraph
G = ig.Graph.Famous("Zachary")
# run leiden 1000 times on this graph from gamma=0 to gamma=2
partitions = repeated_leiden_from_gammas(G, np.linspace(0, 2, 1000))
# prune to the stable partitions from gamma=0 to gamma=2
stable_partitions = prune_to_stable_partitions(G, partitions, 0, 2)
print(stable_partitions)
This prints
[(0, 0, 0, 0, 1, 1, 1, 0, 2, 2, 1, 0, 0, 0, 2, 2, 1, 0, 2, 0, 2, 0, 2, 3, 3, 3, 2, 3, 3, 2, 2, 3, 2, 2)]
which is the stable 4-community split of the Karate Club network.
More Information
The issues (which contains some potential future work) and figure generation runtimes README may also be of interest.
Metadata
Release files for modularitypruning 1.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| modularitypruning-1.5.1.tar.gz | 31.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| modularitypruning-1.5.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 57.6 kB
Release files / modularitypruning-1.5.1.tar.gz
| Download URL | modularitypruning-1.5.1.tar.gz |
|---|---|
| Size | 31.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ffb59e9cc331c33560dbc25d5f617a63588e152d21bf0655fb05f1b8383d2da5
|
|
BLAKE2b-256 checksum How to use checksums |
c2c7b61d6f1f5e5e86824c3967f82f9d87468fdd1bc1ec9265151f867e1854ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / modularitypruning-1.5.1-py3-none-any.whl
| Download URL | modularitypruning-1.5.1-py3-none-any.whl |
|---|---|
| Size | 25.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7030518ebb8126dd4df88a8e8c0b4a08becd2d67d03f085cc6d1e66bb0be4ac9
|
|
BLAKE2b-256 checksum How to use checksums |
43f3408b30cd128bddecc36c7a75de88d7b7b2e88d4902cbbb6517319461cd98
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|