CentralityIndices
CentralityIndices is a Python library for computing centrality indices for weighted directed graphs:
- Bundle Index (BI)
- Pivotal Index (PI)
- Weighted Bundle Index 1 (wBI1)
- Weighted Bundle Index 2 (wBI2)
The library accepts dense numpy.ndarray adjacency matrices and sparse SciPy matrices. For sparse graphs it can store the adjacency matrix in CSC format, which is efficient for extracting incoming edges of a target vertex.
Installation
Install the package in editable mode from the repository root:
pip install -e .
For running tests:
pip install -e ".[test]"
Quick Start
import numpy as np
from centralityindices import CentralityIndices
W = np.array(
[
[0, 0, 0],
[50, 0, 0],
[70, 40, 0],
],
dtype=float,
)
centrality = CentralityIndices(W)
print(centrality.backend)
print(centrality.bundle_index(i=2, q=60, k=3))
print(centrality.pivotal_index(i=2, q=60, k=3))
print(centrality.weighted_bundle_index_1(i=2, q=60, k=3))
print(centrality.weighted_bundle_index_2(i=2, q=60, k=3))
print(centrality.all_indices(i=2, q=60, k=3))
Sparse Matrix Support
The density_threshold parameter controls backend selection. If the fraction of non-zero matrix entries is below the threshold, the graph is stored as scipy.sparse.csc_array; otherwise it is stored as a dense NumPy array.
from scipy.sparse import csc_array
W_sparse = csc_array(W)
centrality = CentralityIndices(W_sparse, density_threshold=0.1)
print(centrality.backend)
Tests
pytest tests/test_coverage.py
Metadata
Release files for centralityindices 0.1.0
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 |
|---|---|---|---|---|
| centralityindices-0.1.0.tar.gz | 15.8 kB | Without provenance | Details for centralityindices-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| centralityindices-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for centralityindices-0.1.0-py3-none-any.whl |
Total release size: 27.8 kB
Release files / centralityindices-0.1.0.tar.gz
| Download URL | centralityindices-0.1.0.tar.gz |
|---|---|
| Size | 15.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
37144729007b2ea9a775139be0ae318ae3ac08bccd554d3b972b845a93467988
|
|
BLAKE2b-256 checksum How to use checksums |
fe8ba581d39ffaae76f2953f73982640e64725f71705b12c90d15a6378a2e0ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.0
|
Release files / centralityindices-0.1.0-py3-none-any.whl
| Download URL | centralityindices-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e08e414c231b78c0bd74db9d40b820fad44e2fe4161bb207c2d59165a127f5fe
|
|
BLAKE2b-256 checksum How to use checksums |
787ace024e0b58f568b1e885711b16ec3164bfa7c8c0901f02e9534acc16ee87
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.0
|
Security for centralityindices 0.1.0
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.