Skip to main content

Pruning tool to identify small subsets of network partitions that are significant from the perspective

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.5.0.tar.gz (31.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

modularitypruning-1.5.0-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: modularitypruning-1.5.0.tar.gz
  • Upload date:
  • Size: 31.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for modularitypruning-1.5.0.tar.gz
Algorithm Hash digest
SHA256 018604267258ddd9f637749b1c289abbe709ef793d8f6ce095356c0b3aa964ef
MD5 21011f6e75edf614c10293b41e4fc8ef
BLAKE2b-256 177e2b24cddf431f3592742f163b7fa38d5d5ad242ccaaad15d601de448865bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for modularitypruning-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7911b333b03466e478587bf81bf54299134efbae9b6081d42009479f1526e2a1
MD5 60e4929ba4da282584bd5c9bbabdce12
BLAKE2b-256 7f5aa77fe1252216366a9b62313defd11e6933a106ce6f2d9cf944cad059f11f

See more details on using hashes here.

Supported by

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