modularitypruning


Namemodularitypruning JSON
Version 1.4.1 PyPI version JSON
download
home_pagehttps://github.com/ragibson/ModularityPruning
SummaryPruning tool to identify small subsets of network partitions that are significant from the perspective of stochastic block model inference.
upload_time2024-10-29 03:05:25
maintainerNone
docs_urlNone
authorRyan Gibson
requires_python<4,>=3.8
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ModularityPruning

![ModularityPruning visualization](docs/example_figures/article_figure_method_visual.png)

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": "https://github.com/ragibson/ModularityPruning",
    "name": "modularitypruning",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Ryan Gibson",
    "author_email": "ryan.alex.gibson@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/79/6d/1fe8f753a1bc427f0e7f80a55c58890ece6127ac87478803373422ac7a9e/modularitypruning-1.4.1.tar.gz",
    "platform": null,
    "description": "# ModularityPruning\n\n![ModularityPruning visualization](docs/example_figures/article_figure_method_visual.png)\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": null,
    "summary": "Pruning tool to identify small subsets of network partitions that are significant from the perspective of stochastic block model inference.",
    "version": "1.4.1",
    "project_urls": {
        "Homepage": "https://github.com/ragibson/ModularityPruning"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "af60a09691b3ddcd527f4fcdeb7db20a91ea52bc9dfccd4fc64ce55c97a75b27",
                "md5": "2377c8fddab880193dae086569a9c10f",
                "sha256": "5980b0846412065bdc4db7a3aa981329cead074ac1c4c53458c035053c2428ba"
            },
            "downloads": -1,
            "filename": "modularitypruning-1.4.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2377c8fddab880193dae086569a9c10f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.8",
            "size": 25834,
            "upload_time": "2024-10-29T03:05:23",
            "upload_time_iso_8601": "2024-10-29T03:05:23.964864Z",
            "url": "https://files.pythonhosted.org/packages/af/60/a09691b3ddcd527f4fcdeb7db20a91ea52bc9dfccd4fc64ce55c97a75b27/modularitypruning-1.4.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "796d1fe8f753a1bc427f0e7f80a55c58890ece6127ac87478803373422ac7a9e",
                "md5": "3b0a962e41a4748ed5bb939597b546cb",
                "sha256": "887b8626cbceaa28857c3cefa899d086edd255be1cc1632b38973353d70922dd"
            },
            "downloads": -1,
            "filename": "modularitypruning-1.4.1.tar.gz",
            "has_sig": false,
            "md5_digest": "3b0a962e41a4748ed5bb939597b546cb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.8",
            "size": 31334,
            "upload_time": "2024-10-29T03:05:25",
            "upload_time_iso_8601": "2024-10-29T03:05:25.526281Z",
            "url": "https://files.pythonhosted.org/packages/79/6d/1fe8f753a1bc427f0e7f80a55c58890ece6127ac87478803373422ac7a9e/modularitypruning-1.4.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-29 03:05:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ragibson",
    "github_project": "ModularityPruning",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "modularitypruning"
}
        
Elapsed time: 0.53328s