Skip to main content

NetGraph

Python-test

Network modeling and analysis framework: Python front end, C++ graph algorithms.

What It Does

NetGraph models network topologies, traffic demands and failure scenarios, and analyzes capacity and resilience. Networks are defined in Python or in YAML; max-flow and failure simulations export reproducible JSON.

Install

pip install ngraph

Python API

from ngraph import (
    CapacityQuery, Link, Network, Node, Scenario, Selector, UnitsSettings,
    capacity, prepare,
)

# Three nodes in a line, joined by links of capacity 10
network = Network()
for name in ("A", "B", "C"):
    network.add_node(Node(name))
network.add_link(Link("A", "B", capacity=10))
network.add_link(Link("B", "C", capacity=10))

# Prepare the graph once, with a bandwidth unit q of 1.
prepared = prepare(Scenario(network, units=UnitsSettings(resolution=1)))
result = capacity(prepared, CapacityQuery(Selector("^A$"), Selector("^C$")))
row = result.cases[0].states["converged"].rows[0]
print(row.result.delivered)
10

It prints 10: native bandwidth results are whole units of one bandwidth unit q, and UnitsSettings(resolution=1) sets q to 1 (Units and the resolution q). A CapacityQuery without a model asks for the most that optimized traffic engineering carries from the sources to the targets (TE_MAXFLOW_UNLIM); cases[0] is the case without failures, states["converged"] its one state and rows[0] the A-to-C answer (Failures: patterns, cases and states). For capacities this small, q = 1 misses the default precision target although nothing is rounded, and prepared.units_report.target_met is false (Precision and the choice of q).

Scenario DSL

For reproducible analysis workflows, define topology, demands, and failure policies in YAML (this is scenarios/readme_example.yml):

# Two Clos sites built from one blueprint and joined spine to spine. The workflow finds
# the largest tested feasible demand multiplier (alpha), then places the demands at that
# alpha under 100 draws of one random link failure.
seed: 42

# A reusable topology template
blueprints:
  Clos_Fabric:
    nodes:
      spine: {count: 2, template: "spine{n}"}
      leaf: {count: 4, template: "leaf{n}"}
    links:
      - {source: /leaf, target: /spine, pattern: mesh, capacity: 100}

# Two instances of the template, linked spine to spine
network:
  nodes:
    site1: {blueprint: Clos_Fabric}
    site2: {blueprint: Clos_Fabric}
  links:
    - {source: site1/spine, target: site2/spine, pattern: one_to_one, capacity: 50}

# One random link fails per draw
failures:
  random_link:
    modes:
      - weight: 1
        rules:
          - {scope: link, mode: choice, count: 1}

# Traffic from the leaves of site1 to the leaves of site2
demands:
  global_traffic:
    - {source: ^site1/leaf/, target: ^site2/leaf/, volume: 100, preset: SHORTEST_PATHS_ECMP}

workflow:
  - type: MaximumSupportedDemand
    name: max_demand
    demand_set: global_traffic
  - type: TrafficMatrixPlacement
    name: placement_at_max
    demand_set: global_traffic
    alpha_from_step: max_demand  # its largest tested feasible alpha
    failure_policy: random_link
    iterations: 100
ngraph run scenarios/readme_example.yml --output results/
jq '.steps[] | select(.name == "max_demand") | .result.alpha_feasible.value' results/readme_example.results.json

A preset chooses routing and admission; SHORTEST_PATHS_ECMP splits whole units equally among equal-cost next hops at each router (Routing models and admission). How NetGraph computes explains the presets such as SHORTEST_PATHS_ECMP, maximum supported demand and the numbers in the results; run(prepare(scenario)) returns the same results in Python.

Capabilities

  • Declarative scenarios: schema-validated YAML and reusable blueprints
  • Failure analysis: weighted failure modes, risk groups, and analysis-time exclusions that leave the base topology untouched
  • Routing models: cost-only IP routing and capacity-aware traffic engineering
  • Traffic placement: ECMP and WCMP splits, maximum flow and demand placement
  • Reproducible results: seeded randomness and stable link ids
  • C++ algorithms with the GIL released, via NetGraph-Core

Documentation

License

MIT License

Requirements

  • Python 3.11+
  • NetGraph-Core (installed automatically)

Metadata

Release files for ngraph 0.27.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ngraph 0.27.0
File Size Uploaded Provenance Actions
ngraph-0.27.0.tar.gz 215.8 kB With provenance Details for ngraph-0.27.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ngraph 0.27.0
File Interpreter ABI Platform Actions
ngraph-0.27.0-py3-none-any.whl Python 3 none any Details for ngraph-0.27.0-py3-none-any.whl

Total release size: 458.9 kB

Release files / ngraph-0.27.0.tar.gz

Download URL ngraph-0.27.0.tar.gz
Size 215.8 kB
Tags Source
SHA-256 checksum
How to use checksums
532fb782361ce335f6320531af278aa9f10e2f42a6bd1500a7022e7e959b1aa6
BLAKE2b-256 checksum
How to use checksums
714f573e0c55f6fbe6de1060c8f6aed15b26b27b4f3b5fc1edd53e2477f3a538
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / ngraph-0.27.0-py3-none-any.whl

Download URL ngraph-0.27.0-py3-none-any.whl
Size 243.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cf56313bda78b026fe3b6f4a3c3fd87e2c905a8f7bfd1642d5c2a3b3d3e5b65b
BLAKE2b-256 checksum
How to use checksums
ac5876022b5d95ed6ba13b34bc881c7676e1a2a185f748144ee976c1ae473b90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Security for ngraph 0.27.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ngraph-0.27.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.27.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page