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 Network, Node, Link, analyze, Mode

# Three nodes in a line
network = Network()
network.add_node(Node("A"))
network.add_node(Node("B"))
network.add_node(Node("C"))
network.add_link(Link("A", "B", capacity=10.0, cost=1.0))
network.add_link(Link("B", "C", capacity=10.0, cost=1.0))

# Compute max flow
result = analyze(network).max_flow("^A$", "^C$", mode=Mode.COMBINE)
print(result)  # {('^A$', '^C$'): 10.0}

Scenario DSL

For reproducible analysis workflows, define topology, demands, and failure policies in YAML:

seed: 42

# Define reusable topology templates
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
        cost: 1

# Instantiate network from templates
network:
  nodes:
    site1: { blueprint: Clos_Fabric }
    site2: { blueprint: Clos_Fabric }
  links:
    - source: { path: site1/spine }
      target: { path: site2/spine }
      pattern: one_to_one
      capacity: 50
      cost: 10

# Define failure policy for Monte Carlo analysis
failures:
  random_link:
    modes:
      - weight: 1.0
        rules:
          - scope: link
            mode: choice
            count: 1

# Define traffic demands
demands:
  global_traffic:
    - source: ^site1/leaf/
      target: ^site2/leaf/
      volume: 100.0
      mode: combine
      flow_policy: SHORTEST_PATHS_ECMP

# Analysis workflow: find max capacity, then test under failures
workflow:
  - type: NetworkStats
    name: stats
  - type: MaxFlow
    name: site_capacity
    source: ^site1/leaf/
    target: ^site2/leaf/
    mode: combine
  - type: MaximumSupportedDemand
    name: max_demand
    demand_set: global_traffic
  - type: TrafficMatrixPlacement
    name: placement_at_max
    demand_set: global_traffic
    alpha_from_step: max_demand # Use alpha_star from MSD step
    failure_policy: random_link
    iterations: 100
ngraph run scenario.yml --output results/
jq '.steps.max_demand.data.alpha_star' results/scenario.results.json

The scenario builds two Clos sites from one blueprint, finds the largest demand multiplier the network carries, then places that demand under 100 random single-link failures and writes the results to JSON.

See DSL Reference and Examples for more.

Capabilities

  • Declarative scenarios: schema-validated YAML, reusable blueprints, a strict multigraph model
  • 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
  • Flow placement: ECMP and WCMP splits, max-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.24.1

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.24.1
File Size Uploaded Provenance
ngraph-0.24.1.tar.gz 171.6 kB With provenance Details

Built distribution (wheel)

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

Total release size: 371.0 kB

Release files / ngraph-0.24.1.tar.gz

Download URL ngraph-0.24.1.tar.gz
Size 171.6 kB
Tags Source
SHA-256 checksum
How to use checksums
79e9f6796099fd8287d10e560710486aaaae9764b008663669ffbf08c9d66767
BLAKE2b-256 checksum
How to use checksums
ab361521080f2272f9082f8bc3553b3196a7d8b5476ca7ec9e9f581fcee597ab
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 24, 2026.

Transparency log

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

Download URL ngraph-0.24.1-py3-none-any.whl
Size 199.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
08071ed39841e196b614df78cea0ea56d85ae7c4a399588b7e3c85498eef107a
BLAKE2b-256 checksum
How to use checksums
b0891b7e3dfc4dd4a47d16d48dad0afb3070988eb2d411ad1f6badafc85e1255
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 24, 2026.

Transparency log

Security for ngraph 0.24.1

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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ngraph-0.24.1.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 24, 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

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