Network centrality library
Project description
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.
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
- Dispersion
- Eigenvector
- Entropy
- Geodestic k path
- Group Betweenness
- Group Closeness
- Group Degree
- Harmonic
- Heatmap
- Katz
- Laplacian
- Leverage
- Lin
- Load
- Mnc
- Pagerank
- Pdi
- Percolation
- Radiality
- Rumor
- Second Order
- Semi Local
- Subgraph
- Topological
- Trophic Levels
- Vote Rank
Code usage
Provided algorithms can be executed in the following ways:
- by importing and using specific method:
from typing import Any
import networkx as nx
from networkx import Graph
from netcenlib.algorithms.algebraic_centrality import algebraic_centrality
- using the
CentralityService
class, which provides access to all centralities through its properties.
from typing import Any
import networkx as nx
from networkx import Graph
from netcenlib.centrality import CentralityService
g: Graph = nx.karate_club_graph()
centrality_service = CentralityService(g)
centrality_centroid: dict[Any, float] = centrality_service.centroid
The biggest advantage of using CentralityService
class is that it allows to compute all centralities at once. Users
have all implementations within reach
- invoking
compute_centrality
method ofCentralityService
class, which allows to compute centrality for a given centrality measure.
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 file.
Maintainers
Project maintainers are:
- Damian Frąszczak
- Edyta Frąszczak
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for netcenlib-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71ac64a40878b9cf146c077f31544873ede13614c470fa7f72f01134e3b0f093 |
|
MD5 | 1b1da945fad70755f5f9662e41c7970d |
|
BLAKE2b-256 | ebad9dc5b0e7d67b7154f9a1d6271e893e8158b9828205926595613ce8e2daeb |