Skip to main content

C++ implementation of graph algorithms for network flow analysis and traffic engineering with Python bindings

Project description

NetGraph-Core

C++ graph engine for network flow analysis, traffic engineering simulation, and capacity planning.

Overview

NetGraph-Core provides a specialized graph implementation for networking problems. Key design priorities:

  • Determinism: Guaranteed reproducible edge ordering by (cost, src, dst).
  • Flow Modeling: Native support for multi-commodity flow state, residual tracking, and ECMP/WCMP placement.
  • Performance: Immutable CSR (Compressed Sparse Row) adjacency and zero-copy NumPy views.

Core Features

1. Graph Representations

  • StrictMultiDiGraph: Immutable directed multigraph using CSR adjacency. Supports parallel edges (multi-graph), essential for network topologies.
  • FlowGraph: Topology overlay managing mutable flow state, per-flow edge allocations, and residual capacities.

2. Network Algorithms

  • Shortest Paths (SPF):

    • Modified Dijkstra returns a Predecessor DAG to capture all equal-cost paths.
    • Supports ECMP (Equal-Cost Multi-Path) routing.
    • Features node/edge masking and residual-aware tie-breaking.
  • K-Shortest Paths (KSP):

    • Yen's algorithm returning DAG-wrapped paths.
    • Configurable constraints on cost factors (e.g., paths within 1.5x of optimal).
  • Max-Flow:

    • Algorithm: Iterative augmentation using Successive Shortest Path on residual graphs, pushing flow across full ECMP/WCMP DAGs at each step.
    • Traffic Engineering (TE) Mode: Routing adapts to residual capacity (progressive fill).
    • IP Routing Mode: Cost-only routing (ECMP/WCMP) ignoring capacity constraints.
  • Analysis:

    • Sensitivity Analysis: Identifies bottleneck edges where capacity relaxation increases total flow. Supports shortest_path mode to analyze only edges used under ECMP routing (IP/IGP networks) vs. full max-flow (SDN/TE networks).
    • Min-Cut: Computes minimum cuts on residual graphs.

3. Flow Policy Engine

Unified configuration object (FlowPolicy) that models diverse routing behaviors:

  • Modeling: Unified configuration for IP Routing (static costs) and Traffic Engineering (dynamic residuals).
  • Placement Strategies:
    • EqualBalanced: ECMP (equal splitting) - equal distribution across next-hops and parallel edges.
    • Proportional: WCMP (weighted splitting) - distribution proportional to residual capacity.
  • Lifecycle Management: Handles demand placement, re-optimization of existing flows, and constraints (path cost, stretch factor, flow counts).

4. Python Integration

  • Zero-Copy: Exposes C++ internal buffers to Python as read-only NumPy arrays (float64/int64).
  • Concurrency: Releases the Python GIL during graph algorithms to enable threading.

Installation

pip install netgraph-core

Or from source:

pip install -e .

Build Optimizations

Default builds include LTO and loop unrolling. For local development:

make install-native   # CPU-specific optimizations (not portable)

Repository Structure

src/                    # C++ implementation
include/netgraph/core/  # Public C++ headers
bindings/python/        # pybind11 bindings
python/netgraph_core/   # Python package
tests/cpp/              # C++ tests (googletest)
tests/py/               # Python tests (pytest)

Development

make dev        # Setup: venv, dependencies, pre-commit hooks
make check      # Run all tests and linting (auto-fix formatting)
make check-ci   # Strict checks without auto-fix (for CI)
make test       # Python tests with coverage
make cpp-test   # C++ tests only
make cov        # Combined coverage report (C++ + Python)

Requirements

  • C++: C++20 compiler (GCC 10+, Clang 12+, MSVC 2019+)
  • Python: 3.11+
  • Build: CMake 3.15+, scikit-build-core
  • Dependencies: pybind11, NumPy

License

AGPL-3.0-or-later

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

netgraph_core-0.3.2.tar.gz (147.9 kB view details)

Uploaded Source

Built Distributions

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

netgraph_core-0.3.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (398.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

netgraph_core-0.3.2-cp313-cp313-macosx_10_13_universal2.whl (518.1 kB view details)

Uploaded CPython 3.13macOS 10.13+ universal2 (ARM64, x86-64)

netgraph_core-0.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (397.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

netgraph_core-0.3.2-cp312-cp312-macosx_10_13_universal2.whl (517.9 kB view details)

Uploaded CPython 3.12macOS 10.13+ universal2 (ARM64, x86-64)

netgraph_core-0.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (396.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

netgraph_core-0.3.2-cp311-cp311-macosx_10_9_universal2.whl (513.6 kB view details)

Uploaded CPython 3.11macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file netgraph_core-0.3.2.tar.gz.

File metadata

  • Download URL: netgraph_core-0.3.2.tar.gz
  • Upload date:
  • Size: 147.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for netgraph_core-0.3.2.tar.gz
Algorithm Hash digest
SHA256 e17f5c1929adbc120358fc142d1b1a9a4dfee73b563825ce5c35e9915e704563
MD5 156ff19db6673ac68f30a303caf5f2bc
BLAKE2b-256 683352170be5e73a9e2bb5f1a63ffb261cb66e6d089316469a85a085a4bd74f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for netgraph_core-0.3.2.tar.gz:

Publisher: release.yml on networmix/NetGraph-Core

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

File details

Details for the file netgraph_core-0.3.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for netgraph_core-0.3.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 13e3802db20654accca76728a1bf8030891bc3a193df9ae47cf3b5fbaf598525
MD5 558b0ea27e4db175dda03c603e109e66
BLAKE2b-256 04ee5c9c47cbe954242670e463b03a3ff861d50116b56b764542b3444cbeff92

See more details on using hashes here.

Provenance

The following attestation bundles were made for netgraph_core-0.3.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on networmix/NetGraph-Core

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

File details

Details for the file netgraph_core-0.3.2-cp313-cp313-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for netgraph_core-0.3.2-cp313-cp313-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 2a802be4a43b0f26c6e62afb933d3249ff529def7423f60dc50a7b7746bfa37b
MD5 94fe80bdad11adc5cdcb1f6dc335b164
BLAKE2b-256 a686e877982ac78858b3f00783a98d084830a7ba9d9773bfa83d6011b26c120b

See more details on using hashes here.

Provenance

The following attestation bundles were made for netgraph_core-0.3.2-cp313-cp313-macosx_10_13_universal2.whl:

Publisher: release.yml on networmix/NetGraph-Core

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

File details

Details for the file netgraph_core-0.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for netgraph_core-0.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5b1292bf78844100b6ecd2b3ec970279983b9173008ae5917734839e42f72a65
MD5 bb59c12812ff87435ee74f842ade7e09
BLAKE2b-256 3069f634d4ab9223d34c5b7665ec88c43c2f5b4cb2bd0be6e12d71c9746f3d46

See more details on using hashes here.

Provenance

The following attestation bundles were made for netgraph_core-0.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on networmix/NetGraph-Core

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

File details

Details for the file netgraph_core-0.3.2-cp312-cp312-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for netgraph_core-0.3.2-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 ab55175d34e3479f4daf966bd61ae9dda03a2d6582656caa280fd89b9de58b04
MD5 4baaebff857d44964cde91890f875911
BLAKE2b-256 0fd6dbaeac5c5a42e66b124f6ddbc3fe0fcf3478222ac60824d6852b6dd89b73

See more details on using hashes here.

Provenance

The following attestation bundles were made for netgraph_core-0.3.2-cp312-cp312-macosx_10_13_universal2.whl:

Publisher: release.yml on networmix/NetGraph-Core

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

File details

Details for the file netgraph_core-0.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for netgraph_core-0.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d03991375871c9c75c351915fdc00e2e70ce654e0cc98d803408445d324bbaea
MD5 dd760d1133030458150af4c7095eef0f
BLAKE2b-256 a11e89613b66adb4cba27d7afb9111955946067f1db0206e2e9478bd0b478811

See more details on using hashes here.

Provenance

The following attestation bundles were made for netgraph_core-0.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on networmix/NetGraph-Core

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

File details

Details for the file netgraph_core-0.3.2-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for netgraph_core-0.3.2-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 c43f6def69fd17df4bcd18a92e5fa686161665c1a52ed5e446e066fdcb3f8d3e
MD5 8308c7d10b9fa8717ebd5aee3e7ac2e2
BLAKE2b-256 e2cda47990354632c2a9681c448641073314504fc30466b3d1e82b52b4f69a2a

See more details on using hashes here.

Provenance

The following attestation bundles were made for netgraph_core-0.3.2-cp311-cp311-macosx_10_9_universal2.whl:

Publisher: release.yml on networmix/NetGraph-Core

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