Network Partitioning & Aggregation Package
Project description
NPAP is an open-source Python library for partitioning and aggregating network graphs, with a special focus on electrical power systems. Built on top of NetworkX, it provides a clean strategy-based architecture that makes it easy to cluster networks and reduce their complexity while preserving essential properties.
Whether you're working with power grids, transportation networks, or any graph-based spatial data, NPAP helps you simplify complex networks into manageable pieces.
[!NOTE] Project contributors from IEE (Institute of Electricity Economics and Energy Innovation) at the Technical University of Graz are supported by the Research Center Energetic and funded by the European Union (ERC, NetZero-Opt, 101116212).
Documentation
For comprehensive guides, API reference, and tutorials, visit the official documentation:
Features
- Multiple Partitioning Algorithms - K-means, K-medoids, DBSCAN, HDBSCAN, and hierarchical clustering
- Distance Metrics - Euclidean for local coordinates, Haversine for geographic data
- Electrical Distance - Partition based on PTDF-derived electrical proximity
- Voltage-Aware Clustering - Respects voltage levels and transformer boundaries
- Flexible Aggregation - Sum, average, or custom strategies for node/edge properties
- Extensible Design - Easy to add your own partitioning or aggregation strategies
Installation
pip install npap
Quick Start
from npap import PartitionAggregatorManager, AggregationProfile, AggregationMode
# 1. Initialize the manager
manager = PartitionAggregatorManager()
# 2. Load data (voltage-aware loader for power systems)
manager.load_data(
strategy='va_loader',
node_file="buses.csv",
line_file="lines.csv",
transformer_file="transformers.csv",
converter_file="converters.csv",
link_file="dc_links.csv"
)
# 3. Aggregate parallel edges (optional)
manager.aggregate_parallel_edges(
edge_properties={"x": "equivalent_reactance", "type": "first"},
default_strategy="average"
)
# 4. Partition the network
manager.partition(strategy="electrical_kmedoids", n_clusters=50)
# 5. Visualize the partitioned network
manager.plot_network(style='clustered', title='Partitioned Network')
# 6. Aggregate with a custom profile
profile = AggregationProfile(
mode=AggregationMode.GEOGRAPHICAL,
topology_strategy="simple",
node_properties={"lat": "average", "lon": "average", "voltage": "average"},
edge_properties={"p_max": "sum", "x": "equivalent_reactance"},
default_node_strategy="average",
default_edge_strategy="average"
)
aggregated_network = manager.aggregate(profile=profile)
# 7. Visualize the reduced network
manager.plot_network(style='simple', title='Aggregated Network')
Contributing
We warmly welcome contributions from everyone! Whether it's fixing a typo, improving documentation, reporting bugs, or implementing new features — every contribution matters.
Please read our Contributing Guide to get started, or visit the full Contributing Documentation for detailed guidelines. Don't hesitate to open an issue if you have questions or ideas!
License
NPAP is released under the MIT License.
Acknowledgements
Funded by the European Union (ERC, NetZero-Opt, 101116212). Views and opinions expressed are however those of the author(s) only and do not necessarily reflect those of the European Union or the European Research Council. Neither the European Union nor the granting authority can be held responsible for them.
Built with care for the open-source community 🫰
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file npap-1.0.2.tar.gz.
File metadata
- Download URL: npap-1.0.2.tar.gz
- Upload date:
- Size: 4.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9543ced12e0efff260aff7c3c5097cdba300d6790179482df1b33175140ed282
|
|
| MD5 |
4599fdae79b0df549f5e9725e5ca6ffb
|
|
| BLAKE2b-256 |
44e254770e9c7613578f9039c6d09fc16582bbbf5951988ffa1ca38c88c3bec7
|
Provenance
The following attestation bundles were made for npap-1.0.2.tar.gz:
Publisher:
publish.yml on IEE-TUGraz/NPAP
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
npap-1.0.2.tar.gz -
Subject digest:
9543ced12e0efff260aff7c3c5097cdba300d6790179482df1b33175140ed282 - Sigstore transparency entry: 1271191086
- Sigstore integration time:
-
Permalink:
IEE-TUGraz/NPAP@022d5ee5db7ac668fc0b68207eddac871d629284 -
Branch / Tag:
refs/tags/1.0.2 - Owner: https://github.com/IEE-TUGraz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@022d5ee5db7ac668fc0b68207eddac871d629284 -
Trigger Event:
release
-
Statement type:
File details
Details for the file npap-1.0.2-py3-none-any.whl.
File metadata
- Download URL: npap-1.0.2-py3-none-any.whl
- Upload date:
- Size: 84.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e9c0a00a3d8aa2af28afdab0d19fdad34ad2444a1ab5ca97a1262f7c34c8ea2
|
|
| MD5 |
78c3f5b53dadb4863d819f26ed1425c4
|
|
| BLAKE2b-256 |
b6a6b1efddbad4d3186a712a678083e9731a40bb4ad6610b117b5725a2657b63
|
Provenance
The following attestation bundles were made for npap-1.0.2-py3-none-any.whl:
Publisher:
publish.yml on IEE-TUGraz/NPAP
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
npap-1.0.2-py3-none-any.whl -
Subject digest:
3e9c0a00a3d8aa2af28afdab0d19fdad34ad2444a1ab5ca97a1262f7c34c8ea2 - Sigstore transparency entry: 1271191234
- Sigstore integration time:
-
Permalink:
IEE-TUGraz/NPAP@022d5ee5db7ac668fc0b68207eddac871d629284 -
Branch / Tag:
refs/tags/1.0.2 - Owner: https://github.com/IEE-TUGraz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@022d5ee5db7ac668fc0b68207eddac871d629284 -
Trigger Event:
release
-
Statement type: