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.26.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.26.0
File Size Uploaded Provenance Actions
ngraph-0.26.0.tar.gz 214.2 kB With provenance Details for ngraph-0.26.0.tar.gz

Built distribution (wheel)

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

Total release size: 455.5 kB

Release files / ngraph-0.26.0.tar.gz

Download URL ngraph-0.26.0.tar.gz
Size 214.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8b7c0b320e4482df8b1b7f960546a1859c978b2eeb462554438c1e2018d3589b
BLAKE2b-256 checksum
How to use checksums
ac55090a9aab97a6e7d89e84cffaa508e0c6f2db58e50096dd4afcf908ea287e
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 Oct 29, 2026.

Transparency log

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

Download URL ngraph-0.26.0-py3-none-any.whl
Size 241.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd0d779f1d762ce018fd8c19b10499655df814adb4fc3a9bda49bccf91cb00a9
BLAKE2b-256 checksum
How to use checksums
70ea1abb15cd14914f02f83efae8ce2afe1ca3589d1ce03f7cf3e5f76a7727de
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 Oct 29, 2026.

Transparency log

Security for ngraph 0.26.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.26.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 Oct 29, 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.26.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