Skip to main content

Network Partitioning & Aggregation Package

Project description

NPAP - Network Partitioning & Aggregation Package

PyPI version Python versions License: MIT Documentation codecov pre-commit.ci status Ruff


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:

https://npap.readthedocs.io

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.

ERC     NetZero-Opt


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

npap-1.0.1.tar.gz (4.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

npap-1.0.1-py3-none-any.whl (84.7 kB view details)

Uploaded Python 3

File details

Details for the file npap-1.0.1.tar.gz.

File metadata

  • Download URL: npap-1.0.1.tar.gz
  • Upload date:
  • Size: 4.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for npap-1.0.1.tar.gz
Algorithm Hash digest
SHA256 c0d1c8dfd30c6b8f555058f0f336563a49a6a744ec2bdfdaa53f742e5247c831
MD5 30599b1da54df2182ad0eb432d4544cf
BLAKE2b-256 37d5505ff17bf0370500a7ebbb172a2c95fb79507c2deeae08e1c1fe46560b3c

See more details on using hashes here.

Provenance

The following attestation bundles were made for npap-1.0.1.tar.gz:

Publisher: publish.yml on IEE-TUGraz/NPAP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file npap-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: npap-1.0.1-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.7

File hashes

Hashes for npap-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bd67537262aa2dd97c2553ad2bb289de364411ecfe380f28f2207b33283191aa
MD5 18d2f905abbac44f1722846c1689f0a4
BLAKE2b-256 4beab3bcdc90be89c2077a2f363ea96720c3a199f9ab851c0e10eda05ecefdc4

See more details on using hashes here.

Provenance

The following attestation bundles were made for npap-1.0.1-py3-none-any.whl:

Publisher: publish.yml on IEE-TUGraz/NPAP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page