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.4.tar.gz (156.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.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (407.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

netgraph_core-0.3.4-cp313-cp313-macosx_10_13_universal2.whl (526.7 kB view details)

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

netgraph_core-0.3.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (405.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

netgraph_core-0.3.4-cp312-cp312-macosx_10_13_universal2.whl (526.5 kB view details)

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

netgraph_core-0.3.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (405.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

netgraph_core-0.3.4-cp311-cp311-macosx_10_9_universal2.whl (522.2 kB view details)

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

File details

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

File metadata

  • Download URL: netgraph_core-0.3.4.tar.gz
  • Upload date:
  • Size: 156.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.4.tar.gz
Algorithm Hash digest
SHA256 f217a3b9da29dd97c5db82d5972a563cc7b05e1357dbade11c6b280f5d589aa9
MD5 165a122304df629a9dafa6f08b07ca90
BLAKE2b-256 daaea28790af2c1990662bc1cbd0159e974df41fe13f1f28da83afd5f21c77ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for netgraph_core-0.3.4.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.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for netgraph_core-0.3.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c48bd4703448fa0f77b8429299d1674f29cc629be45f6855661416ef9f180969
MD5 fbdb94131c2a79c4b25508ebc29fa966
BLAKE2b-256 33ef4c7e571994991baedda52a8f8008dd3edb5863aba167ebb261f4dabc4cbb

See more details on using hashes here.

Provenance

The following attestation bundles were made for netgraph_core-0.3.4-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.4-cp313-cp313-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for netgraph_core-0.3.4-cp313-cp313-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 172094ebf04d8e54457bcf044cf8c9744621900690ce71e26d5c55ed88df984d
MD5 595a75b0262c122bbf234f5c754482a2
BLAKE2b-256 d65258d76ba6368ef91ba83f577176bfebcb5417a0c2fffdc3d2edc743e3359c

See more details on using hashes here.

Provenance

The following attestation bundles were made for netgraph_core-0.3.4-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.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for netgraph_core-0.3.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3ae4987c7ac7c4da15725d03ee93bdba8da9cd0056a675f99ff8674b908843e5
MD5 3e58eea52ae0d9df7f5435a07740f945
BLAKE2b-256 0c9b89bbc60469c35060d5a7dd5fa4ad87e5fb5c6a166d6dc0be68187d9acd5f

See more details on using hashes here.

Provenance

The following attestation bundles were made for netgraph_core-0.3.4-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.4-cp312-cp312-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for netgraph_core-0.3.4-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 8464aca206829b751e4d409e6d08d33a5a20926ea2eeaf94d62c7cfa3569401c
MD5 0615713518fbb261c640ab857e5ba520
BLAKE2b-256 d5d2346536beefad1f4211eaf816278d5cb076ab0d51dc7681c117526bf3ef2f

See more details on using hashes here.

Provenance

The following attestation bundles were made for netgraph_core-0.3.4-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.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for netgraph_core-0.3.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a1ba35ef7df4b29feaf574eee50cdb930bd808aa63410e144fa833f0da53d14d
MD5 dc246284cab6a73bf5ac271c584b9f15
BLAKE2b-256 a13216fbb26e59438be931f4b239cd187f41a0893e6e15e4c931305af1fd7760

See more details on using hashes here.

Provenance

The following attestation bundles were made for netgraph_core-0.3.4-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.4-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for netgraph_core-0.3.4-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 3413cfb42d3fa7060ac5cbf28db7bbf284ac485f28ade852d315584854ddba36
MD5 2f58abb3c11395f06c93fa1a81a7e003
BLAKE2b-256 5cd8fff029c1a7ff71f293a9f4b2cecbabf79d477adb276efa702101b9bb8eec

See more details on using hashes here.

Provenance

The following attestation bundles were made for netgraph_core-0.3.4-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