Pruning tool to identify small subsets of network partitions that are significant from the perspective of stochastic block model inference.
Project description
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.
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
File details
Details for the file modularitypruning-1.4.0.tar.gz
.
File metadata
- Download URL: modularitypruning-1.4.0.tar.gz
- Upload date:
- Size: 31.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3473cf9918ea96c28192a5a556d1d1f0ed8b83516465e6970ff7132eb2c4a9ba |
|
MD5 | d51070652a1c6a0cbf78ce3258701cf0 |
|
BLAKE2b-256 | 2e84bacdca397c653ac612b170a8076e60b53b2043077dafeeb8fc0a60c3649e |
File details
Details for the file modularitypruning-1.4.0-py3-none-any.whl
.
File metadata
- Download URL: modularitypruning-1.4.0-py3-none-any.whl
- Upload date:
- Size: 25.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12cf376c67af83b8412ecbf8f08f72e25c7d8b5c9e62b70ca92c57dcd2e65749 |
|
MD5 | b57f45f327dff2a90ec4d3950116e8e4 |
|
BLAKE2b-256 | 90abf7b00cb7053cf66af7edd2f0e5d08170dd6f7c46cd2ffc19ee6aacf0490f |