netcenlib


Namenetcenlib JSON
Version 0.2.1 PyPI version JSON
download
home_pagehttps://github.com/damianfraszczak/nclib
SummaryNetwork centrality library
upload_time2024-02-23 08:23:39
maintainer
docs_urlNone
authorDamian Frąszczak, Edyta Frąszczak
requires_python
licenseMIT
keywords node_importance centrality_measures centrality complex-networks
VCS
bugtrack_url
requirements networkx numpy scipy
Travis-CI No Travis.
coveralls test coverage
            # NetCenLib

NetCenLib (Network centrality library) is a tool to compute a wide range of centrality measures for a given network. The
library is designed to work with Python Networkx library.

## Overview

The goal of NetCenLib is to offer a comprehensive repository for implementing a broad spectrum of centrality measures. Each
year, new measures are introduced through scientific papers, often with only pseudo-code descriptions, making it
difficult for researchers to evaluate and compare them with existing methods. While implementations of well-known
centrality measures exist, recent innovations are frequently absent. NetCenLib strives to bridge this gap. It references the
renowned CentiServer portal for well-known centrality measures and their originating papers, aiming to encompass all
these measures in the future.

## Code structure

All custom implementations are provided under `netcenlib/algorithms` package. Each centrality measure is implemented in a separate file, named after the measure itself. Correspondingly, each file contains a function, named identically to the file, which calculates the centrality measure. This function accepts a NetworkX graph as input (and other params if applicable) and returns a dictionary, mapping nodes to their centrality values. Ultimately, every custom implementation is made available through the `netcenlib/algorithms` package.
## Implemented centrality measures:

- [Algebraic](https://www.centiserver.org/centrality/Algebraic_Centrality/)
- [Average Distance](https://www.centiserver.org/centrality/Average_Distance/)
- [Barycenter](https://www.centiserver.org/centrality/Barycenter_Centrality/)
- [Betweenness](https://www.centiserver.org/centrality/Shortest-Paths_Betweenness_Centrality/)
- [BottleNeck]( https://www.centiserver.org/centrality/BottleNeck/)
- [Centroid](https://www.centiserver.org/centrality/Centroid_value/)
- [Closeness](https://www.centiserver.org/centrality/Closeness_Centrality/)
- [ClusterRank](https://www.centiserver.org/centrality/ClusterRank/)
- [Communicability Betweenness](https://www.centiserver.org/centrality/Communicability_Betweenness_Centrality/)
- [Coreness](https://www.centiserver.org/centrality/Coreness_Centrality/)
- [Current Flow Betweenness](https://www.centiserver.org/centrality/Current-Flow_Betweenness_Centrality/)
- [Current Flow Closeness](https://www.centiserver.org/centrality/Current-Flow_Closeness_Centrality/)
- [Decay](https://www.centiserver.org/centrality/Decay_Centrality/)
- [Degree](https://www.centiserver.org/centrality/Degree_Centrality/)
- [Diffusion degree](https://www.centiserver.org/centrality/Diffusion_Degree/)
- [Eigenvector](https://www.centiserver.org/centrality/Eigenvector_Centrality/)
- [Entropy](https://www.centiserver.org/centrality/Entropy_Centrality/)
- [Geodestic k path](https://www.centiserver.org/centrality/Geodesic_K-Path_Centrality/)
- [Group Betweenness Centrality](https://www.centiserver.org/centrality/Group_Betweenness_Centrality/)
- [Group Closeness](https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.centrality.group_closeness_centrality.html)
- [Group Degree](https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.centrality.group_degree_centrality.html)
- [Harmonic](https://www.centiserver.org/centrality/Harmonic_Centrality/)
- [Heatmap](https://www.centiserver.org/centrality/Heatmap_Centrality/)
- [Katz](https://www.centiserver.org/centrality/Katz_Centrality/)
- [Hubbell](https://www.centiserver.org/centrality/Hubbell_Centrality/)
- [Laplacian](https://www.centiserver.org/centrality/Laplacian_Centrality/)
- [Leverage](https://www.centiserver.org/centrality/Leverage_Centrality/)
- [Lin](https://www.centiserver.org/centrality/Lin_Centrality/)
- [Load](https://www.centiserver.org/centrality/Load_Centrality/)
- [Mnc](https://www.centiserver.org/centrality/MNC_Maximum_Neighborhood_Component/)
- [Pagerank](https://www.centiserver.org/centrality/PageRank/)
- [Pdi](https://www.centiserver.org/centrality/Pairwise_Disconnectivity_Index/)
- [Percolation](https://www.centiserver.org/centrality/Percolation_Centrality/)
- [Radiality](https://www.centiserver.org/centrality/Radiality_Centrality/)
- [Rumor](https://www.centiserver.org/centrality/Rumor_Centrality/)
- [Second Order](https://www.centiserver.org/centrality/Second_Order_Centrality/)
- [Semi Local](https://www.centiserver.org/centrality/Semi_Local_Centrality/)
- [Subgraph](https://www.centiserver.org/centrality/Subgraph_Centrality/)
- [Topological](https://www.centiserver.org/centrality/Topological_Coefficient/)
- [Trophic Levels](https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.centrality.trophic_levels.html)

## How to use
Library can be installed using pip:

```bash
pip install netcenlib
```

## Code usage

Provided algorithms can be executed in the following ways:

- by invoking a specific function from `netcenlib.algorithms` package, which computes a given centrality measure for a
  given graph.

```python
import networkx as nx
import netcenlib as ncl

# Create a graph
G = nx.karate_club_graph()

# Compute degree centrality
degree_centrality = ncl.degree_centrality(G)

# Compute betweenness centrality
betweenness_centrality = ncl.betweenness_centrality(G)

# Compute closeness centrality
closeness_centrality = ncl.closeness_centrality(G)

# Compute eigenvector centrality
eigenvector_centrality = ncl.eigenvector_centrality(G)
```

- invoking `compute_centrality` method of `CentralityService` class, which allows to compute centrality for a given
  centrality measure.

```python
from typing import Any
import networkx as nx
from networkx import Graph

from netcenlib.centrality import compute_centrality
from netcenlib.taxonomies import Centrality

g: Graph = nx.karate_club_graph()
centrality_centroid: dict[Any, float] = compute_centrality(g, Centrality.CENTROID)
```

This method allows you not to directly specify centrality, making it easy to compute different centralities in a loop.

## Contributing

For contributing, refer to its [CONTRIBUTING.md](.github/CONTRIBUTING.md) file.
We are a welcoming community... just follow the [Code of Conduct](.github/CODE_OF_CONDUCT.md).

## Maintainers

Project maintainers are:

- Damian Frąszczak
- Edyta Frąszczak

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/damianfraszczak/nclib",
    "name": "netcenlib",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "node_importance centrality_measures centrality complex-networks",
    "author": "Damian Fr\u0105szczak, Edyta Fr\u0105szczak",
    "author_email": "damian.fraszczak@wat.edu.pl",
    "download_url": "https://files.pythonhosted.org/packages/5e/85/5d2db0302526d26dceee7a2b6b3ece1e2cfff3e1be29c9cd4287a2aa34f1/netcenlib-0.2.1.tar.gz",
    "platform": null,
    "description": "# NetCenLib\n\nNetCenLib (Network centrality library) is a tool to compute a wide range of centrality measures for a given network. The\nlibrary is designed to work with Python Networkx library.\n\n## Overview\n\nThe goal of NetCenLib is to offer a comprehensive repository for implementing a broad spectrum of centrality measures. Each\nyear, new measures are introduced through scientific papers, often with only pseudo-code descriptions, making it\ndifficult for researchers to evaluate and compare them with existing methods. While implementations of well-known\ncentrality measures exist, recent innovations are frequently absent. NetCenLib strives to bridge this gap. It references the\nrenowned CentiServer portal for well-known centrality measures and their originating papers, aiming to encompass all\nthese measures in the future.\n\n## Code structure\n\nAll custom implementations are provided under `netcenlib/algorithms` package. Each centrality measure is implemented in a separate file, named after the measure itself. Correspondingly, each file contains a function, named identically to the file, which calculates the centrality measure. This function accepts a NetworkX graph as input (and other params if applicable) and returns a dictionary, mapping nodes to their centrality values. Ultimately, every custom implementation is made available through the `netcenlib/algorithms` package.\n## Implemented centrality measures:\n\n- [Algebraic](https://www.centiserver.org/centrality/Algebraic_Centrality/)\n- [Average Distance](https://www.centiserver.org/centrality/Average_Distance/)\n- [Barycenter](https://www.centiserver.org/centrality/Barycenter_Centrality/)\n- [Betweenness](https://www.centiserver.org/centrality/Shortest-Paths_Betweenness_Centrality/)\n- [BottleNeck]( https://www.centiserver.org/centrality/BottleNeck/)\n- [Centroid](https://www.centiserver.org/centrality/Centroid_value/)\n- [Closeness](https://www.centiserver.org/centrality/Closeness_Centrality/)\n- [ClusterRank](https://www.centiserver.org/centrality/ClusterRank/)\n- [Communicability Betweenness](https://www.centiserver.org/centrality/Communicability_Betweenness_Centrality/)\n- [Coreness](https://www.centiserver.org/centrality/Coreness_Centrality/)\n- [Current Flow Betweenness](https://www.centiserver.org/centrality/Current-Flow_Betweenness_Centrality/)\n- [Current Flow Closeness](https://www.centiserver.org/centrality/Current-Flow_Closeness_Centrality/)\n- [Decay](https://www.centiserver.org/centrality/Decay_Centrality/)\n- [Degree](https://www.centiserver.org/centrality/Degree_Centrality/)\n- [Diffusion degree](https://www.centiserver.org/centrality/Diffusion_Degree/)\n- [Eigenvector](https://www.centiserver.org/centrality/Eigenvector_Centrality/)\n- [Entropy](https://www.centiserver.org/centrality/Entropy_Centrality/)\n- [Geodestic k path](https://www.centiserver.org/centrality/Geodesic_K-Path_Centrality/)\n- [Group Betweenness Centrality](https://www.centiserver.org/centrality/Group_Betweenness_Centrality/)\n- [Group Closeness](https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.centrality.group_closeness_centrality.html)\n- [Group Degree](https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.centrality.group_degree_centrality.html)\n- [Harmonic](https://www.centiserver.org/centrality/Harmonic_Centrality/)\n- [Heatmap](https://www.centiserver.org/centrality/Heatmap_Centrality/)\n- [Katz](https://www.centiserver.org/centrality/Katz_Centrality/)\n- [Hubbell](https://www.centiserver.org/centrality/Hubbell_Centrality/)\n- [Laplacian](https://www.centiserver.org/centrality/Laplacian_Centrality/)\n- [Leverage](https://www.centiserver.org/centrality/Leverage_Centrality/)\n- [Lin](https://www.centiserver.org/centrality/Lin_Centrality/)\n- [Load](https://www.centiserver.org/centrality/Load_Centrality/)\n- [Mnc](https://www.centiserver.org/centrality/MNC_Maximum_Neighborhood_Component/)\n- [Pagerank](https://www.centiserver.org/centrality/PageRank/)\n- [Pdi](https://www.centiserver.org/centrality/Pairwise_Disconnectivity_Index/)\n- [Percolation](https://www.centiserver.org/centrality/Percolation_Centrality/)\n- [Radiality](https://www.centiserver.org/centrality/Radiality_Centrality/)\n- [Rumor](https://www.centiserver.org/centrality/Rumor_Centrality/)\n- [Second Order](https://www.centiserver.org/centrality/Second_Order_Centrality/)\n- [Semi Local](https://www.centiserver.org/centrality/Semi_Local_Centrality/)\n- [Subgraph](https://www.centiserver.org/centrality/Subgraph_Centrality/)\n- [Topological](https://www.centiserver.org/centrality/Topological_Coefficient/)\n- [Trophic Levels](https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.centrality.trophic_levels.html)\n\n## How to use\nLibrary can be installed using pip:\n\n```bash\npip install netcenlib\n```\n\n## Code usage\n\nProvided algorithms can be executed in the following ways:\n\n- by invoking a specific function from `netcenlib.algorithms` package, which computes a given centrality measure for a\n  given graph.\n\n```python\nimport networkx as nx\nimport netcenlib as ncl\n\n# Create a graph\nG = nx.karate_club_graph()\n\n# Compute degree centrality\ndegree_centrality = ncl.degree_centrality(G)\n\n# Compute betweenness centrality\nbetweenness_centrality = ncl.betweenness_centrality(G)\n\n# Compute closeness centrality\ncloseness_centrality = ncl.closeness_centrality(G)\n\n# Compute eigenvector centrality\neigenvector_centrality = ncl.eigenvector_centrality(G)\n```\n\n- invoking `compute_centrality` method of `CentralityService` class, which allows to compute centrality for a given\n  centrality measure.\n\n```python\nfrom typing import Any\nimport networkx as nx\nfrom networkx import Graph\n\nfrom netcenlib.centrality import compute_centrality\nfrom netcenlib.taxonomies import Centrality\n\ng: Graph = nx.karate_club_graph()\ncentrality_centroid: dict[Any, float] = compute_centrality(g, Centrality.CENTROID)\n```\n\nThis method allows you not to directly specify centrality, making it easy to compute different centralities in a loop.\n\n## Contributing\n\nFor contributing, refer to its [CONTRIBUTING.md](.github/CONTRIBUTING.md) file.\nWe are a welcoming community... just follow the [Code of Conduct](.github/CODE_OF_CONDUCT.md).\n\n## Maintainers\n\nProject maintainers are:\n\n- Damian Fr\u0105szczak\n- Edyta Fr\u0105szczak\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Network centrality library",
    "version": "0.2.1",
    "project_urls": {
        "Homepage": "https://github.com/damianfraszczak/nclib"
    },
    "split_keywords": [
        "node_importance",
        "centrality_measures",
        "centrality",
        "complex-networks"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6d2f96bb4a82255541bb22864b408826bfb2811f8578f3b4cdc7c1aabcadbdff",
                "md5": "3f750d506dba57a1a81b0fb37f91e2c6",
                "sha256": "bc8cc5e9c092e06bc3b4412439a99fd52141f2b7c9c3cecc4a0fd78098868b42"
            },
            "downloads": -1,
            "filename": "netcenlib-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3f750d506dba57a1a81b0fb37f91e2c6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 23607,
            "upload_time": "2024-02-23T08:23:37",
            "upload_time_iso_8601": "2024-02-23T08:23:37.913029Z",
            "url": "https://files.pythonhosted.org/packages/6d/2f/96bb4a82255541bb22864b408826bfb2811f8578f3b4cdc7c1aabcadbdff/netcenlib-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5e855d2db0302526d26dceee7a2b6b3ece1e2cfff3e1be29c9cd4287a2aa34f1",
                "md5": "edc730bbf1e0515bafc988458405fafd",
                "sha256": "1c36f773dc6f009576d48b87415cda9ed1ddee36929d0f3268547598abf03769"
            },
            "downloads": -1,
            "filename": "netcenlib-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "edc730bbf1e0515bafc988458405fafd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 15001,
            "upload_time": "2024-02-23T08:23:39",
            "upload_time_iso_8601": "2024-02-23T08:23:39.202531Z",
            "url": "https://files.pythonhosted.org/packages/5e/85/5d2db0302526d26dceee7a2b6b3ece1e2cfff3e1be29c9cd4287a2aa34f1/netcenlib-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-23 08:23:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "damianfraszczak",
    "github_project": "nclib",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [
        {
            "name": "networkx",
            "specs": [
                [
                    ">=",
                    "3.0"
                ]
            ]
        },
        {
            "name": "numpy",
            "specs": []
        },
        {
            "name": "scipy",
            "specs": []
        }
    ],
    "lcname": "netcenlib"
}
        
Elapsed time: 0.19578s