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.6.tar.gz (160.7 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.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (426.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

netgraph_core-0.3.6-cp313-cp313-macosx_10_13_universal2.whl (544.9 kB view details)

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

netgraph_core-0.3.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (426.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

netgraph_core-0.3.6-cp312-cp312-macosx_10_13_universal2.whl (544.7 kB view details)

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

netgraph_core-0.3.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (421.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

netgraph_core-0.3.6-cp311-cp311-macosx_10_9_universal2.whl (538.0 kB view details)

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

File details

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

File metadata

  • Download URL: netgraph_core-0.3.6.tar.gz
  • Upload date:
  • Size: 160.7 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.6.tar.gz
Algorithm Hash digest
SHA256 fadd3c31a156119bda5de687f2120810e2785b6b9e36040ae573e98550a2c3b2
MD5 768bd75f7bb5cac926d76cf815ddceae
BLAKE2b-256 657508bcf192aca475b328095822d63ac7fa74c20ea454a235f40f1c65379d0c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for netgraph_core-0.3.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 005179139dbfbfddb94dd488100f845cd3ffbd66464400882da18c4872cb885c
MD5 3895276207743fc172be22e228c642f3
BLAKE2b-256 7a0382b041c02410d17c9af249f92123fa6cc589400e40e2f5c6c0037571297e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for netgraph_core-0.3.6-cp313-cp313-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 715e3299fe723b8baec2b80dd05465d0b5dc298c8513dbd02c36c2bd22f161ea
MD5 3f6e69d7e8776ba5f69384f909666d5b
BLAKE2b-256 27ef304fb55031178ceffabafa037c48823aa1391ad838f39a32ff64e509d3b8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for netgraph_core-0.3.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 944304e86e52e49c06d5133dfe72925382545ee9574fd81891c7aff98ab78a23
MD5 62c0e94fd0c938e934b264633211a0b4
BLAKE2b-256 ef049b4b2defdbb76e06c428b70d2b186976aacd5d5d8b6efa9aad1a427e452e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for netgraph_core-0.3.6-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 edf2a1af7e51dd756ee8003164c2cfeee7b142bedd2c31ca3f0d174481c38fb6
MD5 1c7e84ba71844eb9c755a575538dc6de
BLAKE2b-256 0e6106edd44161390b7e9be1cfd303377c20f08547049262e62c886d85e8f3a8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for netgraph_core-0.3.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fea6f040f3d2208260af148be91c236f7ad1e75d088590bd9d20dbdc9c6bbfea
MD5 01f2874374f948c5bc612e3b1354cfab
BLAKE2b-256 ecea0a524292cc017b6e1820f5a70306ad1374d3fc36ba4ee1c0acfbad8be9f4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for netgraph_core-0.3.6-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 1bd2c903b1452a4eefd1cb9f9716b0e37110ca9833d3ab7ba5a5bb212ecf0517
MD5 039b8c0b091b7fc5425e725dcf438db3
BLAKE2b-256 695795fe6bdb3ab4e37acc819bf0446093ba56ac17d67e95ccb62b836d8faf22

See more details on using hashes here.

Provenance

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