Skip to main content

Pruning tool to identify small subsets of network partitions that are significant from the perspective of stochastic block model inference.

Project description

ModularityPruning

ModularityPruning visualization

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


Download files

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

Source Distribution

modularitypruning-1.3.3.tar.gz (26.3 kB view details)

Uploaded Source

Built Distribution

modularitypruning-1.3.3-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

Details for the file modularitypruning-1.3.3.tar.gz.

File metadata

  • Download URL: modularitypruning-1.3.3.tar.gz
  • Upload date:
  • Size: 26.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for modularitypruning-1.3.3.tar.gz
Algorithm Hash digest
SHA256 37b52406cae82cfa54bd64eb41b04e7cae69cbe83c2fe8bdb75f7957c5b070f7
MD5 e7523d0a9e78c4573d2d7bc733da7e90
BLAKE2b-256 b1cf4cbc50a09237de2da375f8cc8a0aad05922dbf2aa3a724a16c5c7f1e930b

See more details on using hashes here.

File details

Details for the file modularitypruning-1.3.3-py3-none-any.whl.

File metadata

File hashes

Hashes for modularitypruning-1.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3eb77e27c51dfd6b965c32d5ad2e9fcfd4ebe8a947a15cfa0168345fa14bef27
MD5 52463c07ce28e1bd93ed7de17de82a6b
BLAKE2b-256 5fbdad242acd9fd341de0b9df8ef4ef4b227af49bedbd19164cb0ac04a659fd2

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