Skip to main content

A tool and a library for network modeling and analysis.

Project description

NetGraph

Python-test

Network modeling and analysis framework combining Python with high-performance C++ graph algorithms.

What It Does

NetGraph lets you model network topologies, traffic demands, and failure scenarios - then analyze capacity and resilience. Define networks in Python or declarative YAML, run max-flow and failure simulations, and export reproducible JSON results. Compute-intensive algorithms run in C++ with the GIL released.

Install

pip install ngraph

Python API

from ngraph import Network, Node, Link, analyze, Mode

# Build a simple network
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, traffic, 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/

This scenario builds a dual-site Clos fabric from blueprints, finds the maximum supportable demand, then runs 100 Monte Carlo iterations with random link failures - exporting results to JSON.

See DSL Reference and Examples for more.

Capabilities

  • Declarative scenarios with schema validation, reusable blueprints, and strict multigraph representation
  • Failure analysis via policy engine with weighted modes, risk groups, and non-destructive runtime exclusions
  • Routing modes for IP routing (cost-based) and traffic engineering (capacity-aware)
  • Flow placement strategies for ECMP and WCMP with max-flow and capacity envelopes
  • Reproducible results via seeded randomness and stable edge IDs
  • C++ performance with GIL released via NetGraph-Core

Documentation

License

MIT License

Requirements

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

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

ngraph-0.21.0.tar.gz (150.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ngraph-0.21.0-py3-none-any.whl (176.7 kB view details)

Uploaded Python 3

File details

Details for the file ngraph-0.21.0.tar.gz.

File metadata

  • Download URL: ngraph-0.21.0.tar.gz
  • Upload date:
  • Size: 150.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ngraph-0.21.0.tar.gz
Algorithm Hash digest
SHA256 b09dc07d8ee4ed37eb340cc85e8ee4873f865bba43c3bf42fabdb72de4015416
MD5 ee7aeeadfeefde7c51e9a0c10165d6da
BLAKE2b-256 0b92ee343847b545950a3e60557af89ce143765c0301fc4389adb18bf885e651

See more details on using hashes here.

Provenance

The following attestation bundles were made for ngraph-0.21.0.tar.gz:

Publisher: publish.yml on networmix/NetGraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ngraph-0.21.0-py3-none-any.whl.

File metadata

  • Download URL: ngraph-0.21.0-py3-none-any.whl
  • Upload date:
  • Size: 176.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ngraph-0.21.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1d50d78c83133e504c8295be40d6357cb39ecf928879307cda1c2ece06c01a5d
MD5 2208dccb62702bf3485701f3d2402176
BLAKE2b-256 5ff951d3ec799156dc6f737f6633e97bcafebc3bdcc5c7f288416f39457607b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for ngraph-0.21.0-py3-none-any.whl:

Publisher: publish.yml on networmix/NetGraph

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