# 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/)
- [Eccentricity](https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.distance_measures.eccentricity.html)
- [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 centralises in a loop.
For more examples and details, please refer to the [official documentation](https://netcenlib.readthedocs.io/en/latest/index.html).
## 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": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"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/e0/32/109a366084fcbe2c33730d48cb2ba0448b788ce9c0440d11fc8aaf9afa91/netcenlib-0.2.2.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- [Eccentricity](https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.distance_measures.eccentricity.html)\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 centralises in a loop.\n\nFor more examples and details, please refer to the [official documentation](https://netcenlib.readthedocs.io/en/latest/index.html).\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.2",
"project_urls": {
"Homepage": "https://github.com/damianfraszczak/nclib"
},
"split_keywords": [
"node_importance",
"centrality_measures",
"centrality",
"complex-networks"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "73b98491568146f83e7d0d52cbd199c188e180629c4d8ec142c5d2e9205a43ba",
"md5": "86f9145f91d182cbad63522f857fe334",
"sha256": "7ae5613e04837a4bb9e0cd8e01a0f912f04c7c8427e28ce18ee13d16bb6d4b81"
},
"downloads": -1,
"filename": "netcenlib-0.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "86f9145f91d182cbad63522f857fe334",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 24356,
"upload_time": "2024-07-03T09:17:31",
"upload_time_iso_8601": "2024-07-03T09:17:31.433673Z",
"url": "https://files.pythonhosted.org/packages/73/b9/8491568146f83e7d0d52cbd199c188e180629c4d8ec142c5d2e9205a43ba/netcenlib-0.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e032109a366084fcbe2c33730d48cb2ba0448b788ce9c0440d11fc8aaf9afa91",
"md5": "3494f64c12646eba82e42ed0c4c493b6",
"sha256": "314bf0638eaabc1c86babcd5876979a71f8a60c1d172507896ca79ff2f06a6ee"
},
"downloads": -1,
"filename": "netcenlib-0.2.2.tar.gz",
"has_sig": false,
"md5_digest": "3494f64c12646eba82e42ed0c4c493b6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 15360,
"upload_time": "2024-07-03T09:17:32",
"upload_time_iso_8601": "2024-07-03T09:17:32.604744Z",
"url": "https://files.pythonhosted.org/packages/e0/32/109a366084fcbe2c33730d48cb2ba0448b788ce9c0440d11fc8aaf9afa91/netcenlib-0.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-03 09:17:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "damianfraszczak",
"github_project": "nclib",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"requirements": [],
"lcname": "netcenlib"
}