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
- Average Distance
- Barycenter
- Betweenness
- BottleNeck
- Centroid
- Closeness
- ClusterRank
- Communicability Betweenness
- Coreness
- Current Flow Betweenness
- Current Flow Closeness
- Decay
- Degree
- Diffusion degree
- Eccentricity
- Eigenvector
- Entropy
- Geodestic k path
- Group Betweenness Centrality
- Group Closeness
- Group Degree
- Harmonic
- Heatmap
- Katz
- Hubbell
- Laplacian
- Leverage
- Lin
- Load
- Mnc
- Pagerank
- Pdi
- Percolation
- Radiality
- Rumor
- Second Order
- Semi Local
- Subgraph
- Topological
- Trophic Levels
How to use
Library can be installed using pip:
pip install netcenlib
Code usage
Provided algorithms can be executed in the following ways:
- by invoking a specific function from
netcenlib.algorithmspackage, which computes a given centrality measure for a given graph.
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_centralitymethod ofCentralityServiceclass, which allows to compute centrality for a given centrality measure.
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.
Contributing
For contributing, refer to its CONTRIBUTING.md file. We are a welcoming community... just follow the Code of Conduct.
Maintainers
Project maintainers are:
- Damian Frąszczak
- Edyta Frąszczak
Metadata
Release files for netcenlib 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| netcenlib-0.2.2.tar.gz | 15.4 kB | Without provenance | Details for netcenlib-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| netcenlib-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for netcenlib-0.2.2-py3-none-any.whl |
Total release size: 39.7 kB
Release files / netcenlib-0.2.2.tar.gz
| Download URL | netcenlib-0.2.2.tar.gz |
|---|---|
| Size | 15.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
314bf0638eaabc1c86babcd5876979a71f8a60c1d172507896ca79ff2f06a6ee
|
|
BLAKE2b-256 checksum How to use checksums |
e032109a366084fcbe2c33730d48cb2ba0448b788ce9c0440d11fc8aaf9afa91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Release files / netcenlib-0.2.2-py3-none-any.whl
| Download URL | netcenlib-0.2.2-py3-none-any.whl |
|---|---|
| Size | 24.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7ae5613e04837a4bb9e0cd8e01a0f912f04c7c8427e28ce18ee13d16bb6d4b81
|
|
BLAKE2b-256 checksum How to use checksums |
73b98491568146f83e7d0d52cbd199c188e180629c4d8ec142c5d2e9205a43ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Security for netcenlib 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.