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 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 preprint at https://doi.org/10.21203/rs.3.rs-1551680/v1 for more 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.louvain_utilities import repeated_louvain_from_gammas
import numpy as np

# get Karate Club graph in igraph
G = ig.Graph.Famous("Zachary")

# run louvain 1000 times on this graph from gamma=0 to gamma=2
partitions = repeated_louvain_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 TODO items and figure generation runtimes READMEs 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.2.1.tar.gz (2.2 MB view details)

Uploaded Source

Built Distribution

modularitypruning-1.2.1-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: modularitypruning-1.2.1.tar.gz
  • Upload date:
  • Size: 2.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.10

File hashes

Hashes for modularitypruning-1.2.1.tar.gz
Algorithm Hash digest
SHA256 053bc3094491bbfb88ff3bff936ca1941c2c68754187a367e349b2c47615687d
MD5 c1cb4339bf09ef34a9bd590689bfda93
BLAKE2b-256 c52043e3fb007565f2dfffde6c6fdd4de5cb2b59cb8ea7b596e7a7c320c1a794

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for modularitypruning-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b849cde84691388f9b76a03b985f2665a1ffc6b27f9f6698259aed28f0e42031
MD5 189251114d92db743eb23bd086510d19
BLAKE2b-256 4934a4e02f626785dc84a1561d65f50fd0bd83a3f7a20135f63af9761e381d2a

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