| Name | modularitypruning JSON |
| Version |
1.5.0
JSON |
| download |
| home_page | None |
| Summary | Pruning tool to identify small subsets of network partitions that are significant from the perspective |
| upload_time | 2025-10-10 19:35:22 |
| maintainer | None |
| docs_url | None |
| author | None |
| requires_python | >=3.8 |
| license | MIT |
| keywords |
|
| VCS |
|
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# 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](https://modularitypruning.readthedocs.io/en/latest/)
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](
https://static-content.springer.com/esm/art%3A10.1038%2Fs41598-022-20142-6/MediaObjects/41598_2022_20142_MOESM1_ESM.pdf
).
## Installation
This project is on [PyPI](https://pypi.org/project/modularitypruning/) 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
<a name = "Basic Usage"></a>
## Basic Usage
This package interfaces directly with python-igraph. A simple example of its
usage is
```python
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)](https://github.com/ragibson/ModularityPruning/issues)
and [figure generation runtimes README](figure_generation_runtimes.md) may also
be of interest.
Raw data
{
"_id": null,
"home_page": null,
"name": "modularitypruning",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "Ryan Gibson <ryan.alex.gibson@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/17/7e/2b24cddf431f3592742f163b7fa38d5d5ad242ccaaad15d601de448865bf/modularitypruning-1.5.0.tar.gz",
"platform": null,
"description": "# ModularityPruning\n\n\n\nModularityPruning is a pruning tool to identify small subsets of network\npartitions that are significant from the perspective of stochastic block model\ninference. This method works for single-layer and multi-layer networks, as well\nas for restricting focus to a fixed number of communities when desired.\n\nSee the [documentation](https://modularitypruning.readthedocs.io/en/latest/)\nor the journal article at https://doi.org/10.1038/s41598-022-20142-6 for more\ninformation.\n\nSignificantly more details can be found in the article's\n[Supplementary Information](\nhttps://static-content.springer.com/esm/art%3A10.1038%2Fs41598-022-20142-6/MediaObjects/41598_2022_20142_MOESM1_ESM.pdf\n).\n\n## Installation\n\nThis project is on [PyPI](https://pypi.org/project/modularitypruning/) and can\nbe installed with\n\n pip install modularitypruning\n # OR\n pip3 install modularitypruning\n\nAlternatively, you can install it from this repository directly:\n\n git clone https://github.com/ragibson/ModularityPruning\n cd ModularityPruning\n python3 setup.py install\n\n<a name = \"Basic Usage\"></a>\n\n## Basic Usage\n\nThis package interfaces directly with python-igraph. A simple example of its\nusage is\n\n```python\nimport igraph as ig\nfrom modularitypruning import prune_to_stable_partitions\nfrom modularitypruning.leiden_utilities import repeated_leiden_from_gammas\nimport numpy as np\n\n# get Karate Club graph in igraph\nG = ig.Graph.Famous(\"Zachary\")\n\n# run leiden 1000 times on this graph from gamma=0 to gamma=2\npartitions = repeated_leiden_from_gammas(G, np.linspace(0, 2, 1000))\n\n# prune to the stable partitions from gamma=0 to gamma=2\nstable_partitions = prune_to_stable_partitions(G, partitions, 0, 2)\nprint(stable_partitions)\n``` \n\nThis prints\n\n [(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)]\n\nwhich is the stable 4-community split of the Karate Club network.\n\n## More Information\n\nThe [issues (which contains some potential future work)](https://github.com/ragibson/ModularityPruning/issues)\nand [figure generation runtimes README](figure_generation_runtimes.md) may also\nbe of interest.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Pruning tool to identify small subsets of network partitions that are significant from the perspective",
"version": "1.5.0",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "7f5aa77fe1252216366a9b62313defd11e6933a106ce6f2d9cf944cad059f11f",
"md5": "60e4929ba4da282584bd5c9bbabdce12",
"sha256": "7911b333b03466e478587bf81bf54299134efbae9b6081d42009479f1526e2a1"
},
"downloads": -1,
"filename": "modularitypruning-1.5.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "60e4929ba4da282584bd5c9bbabdce12",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 25863,
"upload_time": "2025-10-10T19:35:21",
"upload_time_iso_8601": "2025-10-10T19:35:21.638258Z",
"url": "https://files.pythonhosted.org/packages/7f/5a/a77fe1252216366a9b62313defd11e6933a106ce6f2d9cf944cad059f11f/modularitypruning-1.5.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "177e2b24cddf431f3592742f163b7fa38d5d5ad242ccaaad15d601de448865bf",
"md5": "21011f6e75edf614c10293b41e4fc8ef",
"sha256": "018604267258ddd9f637749b1c289abbe709ef793d8f6ce095356c0b3aa964ef"
},
"downloads": -1,
"filename": "modularitypruning-1.5.0.tar.gz",
"has_sig": false,
"md5_digest": "21011f6e75edf614c10293b41e4fc8ef",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 31269,
"upload_time": "2025-10-10T19:35:22",
"upload_time_iso_8601": "2025-10-10T19:35:22.934003Z",
"url": "https://files.pythonhosted.org/packages/17/7e/2b24cddf431f3592742f163b7fa38d5d5ad242ccaaad15d601de448865bf/modularitypruning-1.5.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-10 19:35:22",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "modularitypruning"
}