ngraph 0.12.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ngraph-0.12.2/LICENSE +148 -0
- ngraph-0.12.2/PKG-INFO +238 -0
- ngraph-0.12.2/README.md +191 -0
- ngraph-0.12.2/ngraph/__init__.py +80 -0
- ngraph-0.12.2/ngraph/__main__.py +8 -0
- ngraph-0.12.2/ngraph/_version.py +5 -0
- ngraph-0.12.2/ngraph/analysis/__init__.py +91 -0
- ngraph-0.12.2/ngraph/analysis/context.py +1661 -0
- ngraph-0.12.2/ngraph/cli.py +1299 -0
- ngraph-0.12.2/ngraph/dsl/__init__.py +7 -0
- ngraph-0.12.2/ngraph/dsl/blueprints/__init__.py +5 -0
- ngraph-0.12.2/ngraph/dsl/blueprints/expand.py +985 -0
- ngraph-0.12.2/ngraph/dsl/blueprints/parser.py +130 -0
- ngraph-0.12.2/ngraph/dsl/loader.py +115 -0
- ngraph-0.12.2/ngraph/exec/analysis/__init__.py +19 -0
- ngraph-0.12.2/ngraph/exec/analysis/flow.py +474 -0
- ngraph-0.12.2/ngraph/exec/demand/__init__.py +5 -0
- ngraph-0.12.2/ngraph/exec/demand/builder.py +101 -0
- ngraph-0.12.2/ngraph/exec/demand/expand.py +199 -0
- ngraph-0.12.2/ngraph/exec/failure/__init__.py +8 -0
- ngraph-0.12.2/ngraph/exec/failure/manager.py +1177 -0
- ngraph-0.12.2/ngraph/explorer.py +889 -0
- ngraph-0.12.2/ngraph/lib/__init__.py +13 -0
- ngraph-0.12.2/ngraph/lib/nx.py +327 -0
- ngraph-0.12.2/ngraph/logging.py +119 -0
- ngraph-0.12.2/ngraph/model/__init__.py +10 -0
- ngraph-0.12.2/ngraph/model/components.py +413 -0
- ngraph-0.12.2/ngraph/model/demand/matrix.py +100 -0
- ngraph-0.12.2/ngraph/model/demand/spec.py +54 -0
- ngraph-0.12.2/ngraph/model/failure/__init__.py +13 -0
- ngraph-0.12.2/ngraph/model/failure/conditions.py +110 -0
- ngraph-0.12.2/ngraph/model/failure/parser.py +140 -0
- ngraph-0.12.2/ngraph/model/failure/policy.py +602 -0
- ngraph-0.12.2/ngraph/model/failure/policy_set.py +66 -0
- ngraph-0.12.2/ngraph/model/flow/policy_config.py +218 -0
- ngraph-0.12.2/ngraph/model/network.py +387 -0
- ngraph-0.12.2/ngraph/model/path.py +205 -0
- ngraph-0.12.2/ngraph/profiling/__init__.py +28 -0
- ngraph-0.12.2/ngraph/profiling/profiler.py +621 -0
- ngraph-0.12.2/ngraph/py.typed +0 -0
- ngraph-0.12.2/ngraph/results/__init__.py +11 -0
- ngraph-0.12.2/ngraph/results/artifacts.py +448 -0
- ngraph-0.12.2/ngraph/results/flow.py +370 -0
- ngraph-0.12.2/ngraph/results/snapshot.py +72 -0
- ngraph-0.12.2/ngraph/results/store.py +229 -0
- ngraph-0.12.2/ngraph/scenario.py +261 -0
- ngraph-0.12.2/ngraph/schemas/__init__.py +4 -0
- ngraph-0.12.2/ngraph/schemas/scenario.json +719 -0
- ngraph-0.12.2/ngraph/types/__init__.py +6 -0
- ngraph-0.12.2/ngraph/types/base.py +50 -0
- ngraph-0.12.2/ngraph/types/dto.py +47 -0
- ngraph-0.12.2/ngraph/utils/__init__.py +20 -0
- ngraph-0.12.2/ngraph/utils/ids.py +18 -0
- ngraph-0.12.2/ngraph/utils/nodes.py +92 -0
- ngraph-0.12.2/ngraph/utils/output_paths.py +121 -0
- ngraph-0.12.2/ngraph/utils/seed_manager.py +83 -0
- ngraph-0.12.2/ngraph/utils/yaml_utils.py +38 -0
- ngraph-0.12.2/ngraph/workflow/__init__.py +20 -0
- ngraph-0.12.2/ngraph/workflow/base.py +203 -0
- ngraph-0.12.2/ngraph/workflow/build_graph.py +123 -0
- ngraph-0.12.2/ngraph/workflow/cost_power.py +238 -0
- ngraph-0.12.2/ngraph/workflow/max_flow_step.py +193 -0
- ngraph-0.12.2/ngraph/workflow/maximum_supported_demand_step.py +336 -0
- ngraph-0.12.2/ngraph/workflow/network_stats.py +191 -0
- ngraph-0.12.2/ngraph/workflow/parse.py +82 -0
- ngraph-0.12.2/ngraph/workflow/traffic_matrix_placement_step.py +275 -0
- ngraph-0.12.2/ngraph.egg-info/PKG-INFO +238 -0
- ngraph-0.12.2/ngraph.egg-info/SOURCES.txt +72 -0
- ngraph-0.12.2/ngraph.egg-info/dependency_links.txt +1 -0
- ngraph-0.12.2/ngraph.egg-info/entry_points.txt +2 -0
- ngraph-0.12.2/ngraph.egg-info/requires.txt +24 -0
- ngraph-0.12.2/ngraph.egg-info/top_level.txt +1 -0
- ngraph-0.12.2/pyproject.toml +150 -0
- ngraph-0.12.2/setup.cfg +4 -0
ngraph-0.12.2/LICENSE
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
GNU AFFERO GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 19 November 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
Preamble
|
|
9
|
+
|
|
10
|
+
The GNU Affero General Public License is a free, copyleft license for
|
|
11
|
+
software and other kinds of works, specifically designed to ensure
|
|
12
|
+
cooperation with the community in the case of network server software.
|
|
13
|
+
|
|
14
|
+
The licenses for most software and other practical works are designed
|
|
15
|
+
to take away your freedom to share and change the works. By contrast,
|
|
16
|
+
our General Public Licenses are intended to guarantee your freedom to
|
|
17
|
+
share and change all versions of a program--to make sure it remains free
|
|
18
|
+
software for all its users.
|
|
19
|
+
|
|
20
|
+
When we speak of free software, we are referring to freedom, not
|
|
21
|
+
price. Our General Public Licenses are designed to make sure that you
|
|
22
|
+
have the freedom to distribute copies of free software (and charge for
|
|
23
|
+
them if you wish), that you receive source code or can get it if you
|
|
24
|
+
want it, that you can change the software or use pieces of it in new
|
|
25
|
+
free programs, and that you know you can do these things.
|
|
26
|
+
|
|
27
|
+
Developers that use our General Public Licenses protect your rights
|
|
28
|
+
with two steps: (1) assert copyright on the software, and (2) offer
|
|
29
|
+
you this License which gives you legal permission to copy, distribute
|
|
30
|
+
and/or modify the software.
|
|
31
|
+
|
|
32
|
+
A secondary benefit of defending all users' freedom is that
|
|
33
|
+
improvements made in alternate versions of the program, if they
|
|
34
|
+
receive widespread use, become available for other developers to
|
|
35
|
+
incorporate. Many developers of free software are heartened and
|
|
36
|
+
encouraged by the resulting cooperation. However, in the case of
|
|
37
|
+
software used on network servers, this result may fail to come about.
|
|
38
|
+
The GNU General Public License permits making a modified version and
|
|
39
|
+
letting the public access it on a server without ever releasing its
|
|
40
|
+
source code to the public.
|
|
41
|
+
|
|
42
|
+
The GNU Affero General Public License is designed specifically to
|
|
43
|
+
ensure that, in such cases, the modified source code becomes available
|
|
44
|
+
to the community. It requires the operator of a network server to
|
|
45
|
+
provide the source code of the modified version running there to the
|
|
46
|
+
users of that server. Therefore, public use of a modified version, on
|
|
47
|
+
a publicly accessible server, gives the public access to the source
|
|
48
|
+
code of the modified version.
|
|
49
|
+
|
|
50
|
+
An older license, called the Affero General Public License and
|
|
51
|
+
published by Affero, was designed to accomplish similar goals. This is
|
|
52
|
+
a different license, not a version of the Affero GPL, but Affero has
|
|
53
|
+
released a new version of the Affero GPL which permits relicensing under
|
|
54
|
+
this license.
|
|
55
|
+
|
|
56
|
+
The precise terms and conditions for copying, distribution and
|
|
57
|
+
modification follow.
|
|
58
|
+
|
|
59
|
+
TERMS AND CONDITIONS
|
|
60
|
+
|
|
61
|
+
0. Definitions.
|
|
62
|
+
|
|
63
|
+
"This License" refers to version 3 of the GNU Affero General Public License.
|
|
64
|
+
|
|
65
|
+
"Copyright" also means copyright-like laws that apply to other kinds of
|
|
66
|
+
works, such as semiconductor masks.
|
|
67
|
+
|
|
68
|
+
"The Program" refers to any copyrightable work licensed under this
|
|
69
|
+
License. Each licensee is addressed as "you". "Licensees" and
|
|
70
|
+
"recipients" may be individuals or organizations.
|
|
71
|
+
|
|
72
|
+
To "modify" a work means to copy from or adapt all or part of the work
|
|
73
|
+
in a fashion requiring copyright permission, other than the making of an
|
|
74
|
+
exact copy. The resulting work is called a "modified version" of the
|
|
75
|
+
earlier work or a work "based on" the earlier work.
|
|
76
|
+
|
|
77
|
+
A "covered work" means either the unmodified Program or a work based
|
|
78
|
+
on the Program.
|
|
79
|
+
|
|
80
|
+
To "propagate" a work means to do anything with it that, without
|
|
81
|
+
permission, would make you directly or secondarily liable for
|
|
82
|
+
infringement under applicable copyright law, except executing it on a
|
|
83
|
+
computer or modifying a private copy. Propagation includes copying,
|
|
84
|
+
distribution (with or without modification), making available to the
|
|
85
|
+
public, and in some countries other activities as well.
|
|
86
|
+
|
|
87
|
+
To "convey" a work means any kind of propagation that enables other
|
|
88
|
+
parties to make or receive copies. Mere interaction with a user through
|
|
89
|
+
a computer network, with no transfer of a copy, is not conveying.
|
|
90
|
+
|
|
91
|
+
An interactive user interface displays "Appropriate Legal Notices"
|
|
92
|
+
to the extent that it includes a convenient and prominently visible
|
|
93
|
+
feature that (1) displays an appropriate copyright notice, and (2)
|
|
94
|
+
tells the user that there is no warranty for the work (except to the
|
|
95
|
+
extent that warranties are provided), that licensees may convey the
|
|
96
|
+
work under this License, and how to view a copy of this License. If
|
|
97
|
+
the interface presents a list of user commands or options, such as a
|
|
98
|
+
menu, a prominent item in the list meets this criterion.
|
|
99
|
+
|
|
100
|
+
1. Source Code.
|
|
101
|
+
|
|
102
|
+
The "source code" for a work means the preferred form of the work
|
|
103
|
+
for making modifications to it. "Object code" means any non-source
|
|
104
|
+
form of a work.
|
|
105
|
+
|
|
106
|
+
... (AGPLv3 full text continues; include the entire standard text without modification) ...
|
|
107
|
+
|
|
108
|
+
How to Apply These Terms to Your New Programs
|
|
109
|
+
|
|
110
|
+
If you develop a new program, and you want it to be of the greatest
|
|
111
|
+
possible use to the public, the best way to achieve this is to make it
|
|
112
|
+
free software which everyone can redistribute and change under these terms.
|
|
113
|
+
|
|
114
|
+
To do so, attach the following notices to the program. It is safest
|
|
115
|
+
to attach them to the start of each source file to most effectively
|
|
116
|
+
state the exclusion of warranty; and each file should have at least
|
|
117
|
+
the "copyright" line and a pointer to where the full notice is found.
|
|
118
|
+
|
|
119
|
+
<one line to give the program's name and a brief idea of what it does.>
|
|
120
|
+
Copyright (C) <year> <name of author>
|
|
121
|
+
|
|
122
|
+
This program is free software: you can redistribute it and/or modify
|
|
123
|
+
it under the terms of the GNU Affero General Public License as published by
|
|
124
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
125
|
+
(at your option) any later version.
|
|
126
|
+
|
|
127
|
+
This program is distributed in the hope that it will be useful,
|
|
128
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
129
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
130
|
+
GNU Affero General Public License for more details.
|
|
131
|
+
|
|
132
|
+
You should have received a copy of the GNU Affero General Public License
|
|
133
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
134
|
+
|
|
135
|
+
Also add information on how to contact you by electronic and paper mail.
|
|
136
|
+
|
|
137
|
+
If your software can interact with users remotely through a computer
|
|
138
|
+
network, you should also make sure that it provides a way for users to
|
|
139
|
+
get its source. For example, if your program is a web application, its
|
|
140
|
+
interface could display a "Source" link that leads users to an archive
|
|
141
|
+
of the code. There are many ways you could offer source, and different
|
|
142
|
+
solutions will be better for different programs; see section 13 for the
|
|
143
|
+
specific requirements.
|
|
144
|
+
|
|
145
|
+
You should also get your employer (if you work as a programmer) or school,
|
|
146
|
+
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
|
147
|
+
For more information on this, and how to apply and follow the GNU AGPL, see
|
|
148
|
+
<https://www.gnu.org/licenses/>.
|
ngraph-0.12.2/PKG-INFO
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ngraph
|
|
3
|
+
Version: 0.12.2
|
|
4
|
+
Summary: A tool and a library for network modeling and analysis.
|
|
5
|
+
Author: Andrey Golovanov
|
|
6
|
+
License-Expression: AGPL-3.0-or-later
|
|
7
|
+
Project-URL: Homepage, https://github.com/networmix/NetGraph
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering
|
|
12
|
+
Classifier: Topic :: System :: Networking
|
|
13
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: networkx>=3.0
|
|
24
|
+
Requires-Dist: pyyaml>=6.0
|
|
25
|
+
Requires-Dist: pandas>=2.0
|
|
26
|
+
Requires-Dist: jsonschema>=4.0
|
|
27
|
+
Requires-Dist: netgraph-core>=0.3.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
31
|
+
Requires-Dist: pytest-benchmark; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest-mock; extra == "dev"
|
|
33
|
+
Requires-Dist: pytest-timeout; extra == "dev"
|
|
34
|
+
Requires-Dist: numpy; extra == "dev"
|
|
35
|
+
Requires-Dist: matplotlib; extra == "dev"
|
|
36
|
+
Requires-Dist: seaborn; extra == "dev"
|
|
37
|
+
Requires-Dist: mkdocs-material; extra == "dev"
|
|
38
|
+
Requires-Dist: pdoc; extra == "dev"
|
|
39
|
+
Requires-Dist: ruff==0.11.13; extra == "dev"
|
|
40
|
+
Requires-Dist: pyright==1.1.401; extra == "dev"
|
|
41
|
+
Requires-Dist: pandas-stubs; extra == "dev"
|
|
42
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
43
|
+
Requires-Dist: build; extra == "dev"
|
|
44
|
+
Requires-Dist: twine; extra == "dev"
|
|
45
|
+
Requires-Dist: jsonschema; extra == "dev"
|
|
46
|
+
Dynamic: license-file
|
|
47
|
+
|
|
48
|
+
# NetGraph
|
|
49
|
+
|
|
50
|
+
[](https://github.com/networmix/NetGraph/actions/workflows/python-test.yml)
|
|
51
|
+
|
|
52
|
+
Scenario-driven network modeling and analysis framework combining Python's flexibility with high-performance C++ algorithms.
|
|
53
|
+
|
|
54
|
+
## Overview
|
|
55
|
+
|
|
56
|
+
NetGraph enables declarative modeling of network topologies, traffic matrices, and failure scenarios. It delegates computationally intensive graph algorithms to [NetGraph-Core](https://github.com/networmix/NetGraph-Core) while providing a rich Python API and CLI for orchestration.
|
|
57
|
+
|
|
58
|
+
## Architecture
|
|
59
|
+
|
|
60
|
+
NetGraph employs a **hybrid Python+C++ architecture**:
|
|
61
|
+
|
|
62
|
+
- **Python layer (NetGraph)**: Scenario DSL parsing, workflow orchestration, result aggregation, and high-level APIs.
|
|
63
|
+
- **C++ layer (NetGraph-Core)**: Performance-critical graph algorithms (SPF, KSP, Max-Flow) executing in optimized C++ with the GIL released.
|
|
64
|
+
|
|
65
|
+
## Key Features
|
|
66
|
+
|
|
67
|
+
### 1. Modeling & DSL
|
|
68
|
+
|
|
69
|
+
- **Declarative Scenarios**: Define topology, traffic, and workflows in validated YAML.
|
|
70
|
+
- **Blueprints**: Reusable topology templates (e.g., Clos fabrics, regions) with parameterized expansion.
|
|
71
|
+
- **Strict Multigraph**: Deterministic graph representation with stable edge IDs.
|
|
72
|
+
|
|
73
|
+
### 2. Failure Analysis
|
|
74
|
+
|
|
75
|
+
- **Policy Engine**: Weighted failure modes with multiple policy rules per mode.
|
|
76
|
+
- **Non-Destructive**: Runtime exclusions simulate failures without modifying the base topology.
|
|
77
|
+
- **Risk Groups**: Model shared fate (e.g., fiber cuts, power zones).
|
|
78
|
+
|
|
79
|
+
### 3. Traffic Engineering
|
|
80
|
+
|
|
81
|
+
- **Routing Modes**: Unified modeling of **IP Routing** (static costs, oblivious to congestion) and **Traffic Engineering** (dynamic residuals, congestion-aware).
|
|
82
|
+
- **Flow Placement**: Strategies for **ECMP** (Equal-Cost Multi-Path) and **WCMP** (Weighted Cost Multi-Path).
|
|
83
|
+
- **Capacity Analysis**: Compute max-flow envelopes and demand allocation with configurable placement policies.
|
|
84
|
+
|
|
85
|
+
### 4. Workflow & Integration
|
|
86
|
+
|
|
87
|
+
- **Structured Results**: Export analysis artifacts to JSON for downstream processing.
|
|
88
|
+
- **CLI**: Comprehensive command-line interface for validation and execution.
|
|
89
|
+
- **Python API**: Full programmatic access to all modeling and solving capabilities.
|
|
90
|
+
|
|
91
|
+
## Installation
|
|
92
|
+
|
|
93
|
+
### From PyPI
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
pip install ngraph
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### From Source
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
git clone https://github.com/networmix/NetGraph
|
|
103
|
+
cd NetGraph
|
|
104
|
+
make dev # Install in editable mode with dev dependencies
|
|
105
|
+
make check # Run full test suite
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Quick Start
|
|
109
|
+
|
|
110
|
+
### CLI Usage
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# Validate and inspect a scenario
|
|
114
|
+
ngraph inspect scenarios/backbone_clos.yml --detail
|
|
115
|
+
|
|
116
|
+
# Run analysis workflow
|
|
117
|
+
ngraph run scenarios/backbone_clos.yml --results clos.results.json
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Python API
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from ngraph import Network, Node, Link, analyze, Mode
|
|
124
|
+
|
|
125
|
+
# Build network programmatically
|
|
126
|
+
network = Network()
|
|
127
|
+
network.add_node(Node("A"))
|
|
128
|
+
network.add_node(Node("B"))
|
|
129
|
+
network.add_node(Node("C"))
|
|
130
|
+
network.add_link(Link("A", "B", capacity=10.0, cost=1.0))
|
|
131
|
+
network.add_link(Link("B", "C", capacity=10.0, cost=1.0))
|
|
132
|
+
|
|
133
|
+
# Compute max flow with the analyze() API
|
|
134
|
+
flow = analyze(network).max_flow("^A$", "^C$", mode=Mode.COMBINE)
|
|
135
|
+
print(f"Max flow: {flow}") # {('^A$', '^C$'): 10.0}
|
|
136
|
+
|
|
137
|
+
# Efficient repeated analysis with bound context
|
|
138
|
+
ctx = analyze(network, source="^A$", sink="^C$", mode=Mode.COMBINE)
|
|
139
|
+
baseline = ctx.max_flow()
|
|
140
|
+
degraded = ctx.max_flow(excluded_nodes={"B"}) # Test failure scenario
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Example Scenario
|
|
144
|
+
|
|
145
|
+
NetGraph scenarios define topology, configuration, and analysis steps in a unified YAML file. This example demonstrates **blueprints** for modular topology definition:
|
|
146
|
+
|
|
147
|
+
```yaml
|
|
148
|
+
seed: 42
|
|
149
|
+
|
|
150
|
+
# Define reusable topology templates
|
|
151
|
+
blueprints:
|
|
152
|
+
Clos_Fabric:
|
|
153
|
+
groups:
|
|
154
|
+
spine: {node_count: 2, name_template: "spine{node_num}"}
|
|
155
|
+
leaf: {node_count: 4, name_template: "leaf{node_num}"}
|
|
156
|
+
adjacency:
|
|
157
|
+
- source: /leaf
|
|
158
|
+
target: /spine
|
|
159
|
+
pattern: mesh
|
|
160
|
+
link_params: {capacity: 100, cost: 1}
|
|
161
|
+
- source: /spine
|
|
162
|
+
target: /leaf
|
|
163
|
+
pattern: mesh
|
|
164
|
+
link_params: {capacity: 100, cost: 1}
|
|
165
|
+
|
|
166
|
+
# Instantiate network from templates
|
|
167
|
+
network:
|
|
168
|
+
groups:
|
|
169
|
+
site1: {use_blueprint: Clos_Fabric}
|
|
170
|
+
site2: {use_blueprint: Clos_Fabric}
|
|
171
|
+
adjacency:
|
|
172
|
+
- source: {path: site1/spine}
|
|
173
|
+
target: {path: site2/spine}
|
|
174
|
+
pattern: one_to_one
|
|
175
|
+
link_params: {capacity: 50, cost: 10}
|
|
176
|
+
|
|
177
|
+
# Define traffic matrix
|
|
178
|
+
traffic_matrix_set:
|
|
179
|
+
global_traffic:
|
|
180
|
+
- source_path: ^site1/leaf/
|
|
181
|
+
sink_path: ^site2/leaf/
|
|
182
|
+
demand: 100.0
|
|
183
|
+
mode: combine
|
|
184
|
+
flow_policy_config: SHORTEST_PATHS_ECMP
|
|
185
|
+
|
|
186
|
+
# Define analysis workflow
|
|
187
|
+
workflow:
|
|
188
|
+
- step_type: NetworkStats
|
|
189
|
+
name: stats
|
|
190
|
+
- step_type: MaxFlow
|
|
191
|
+
name: site_capacity
|
|
192
|
+
source_path: ^site1/leaf/
|
|
193
|
+
sink_path: ^site2/leaf/
|
|
194
|
+
mode: combine
|
|
195
|
+
shortest_path: false
|
|
196
|
+
- step_type: MaximumSupportedDemand
|
|
197
|
+
name: max_demand
|
|
198
|
+
matrix_name: global_traffic
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Repository Structure
|
|
202
|
+
|
|
203
|
+
```text
|
|
204
|
+
ngraph/ # Python package source
|
|
205
|
+
dsl/ # Scenario parsing and blueprint expansion
|
|
206
|
+
model/ # Network and flow domain models
|
|
207
|
+
solver/ # Algorithms and Core wrappers
|
|
208
|
+
workflow/ # Analysis steps and orchestration
|
|
209
|
+
scenarios/ # Example scenario definitions
|
|
210
|
+
tests/ # Pytest suite (unit and integration)
|
|
211
|
+
docs/ # Documentation source (MkDocs)
|
|
212
|
+
dev/ # Development tools and scripts
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Development
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
make dev # Setup environment
|
|
219
|
+
make check # Run tests and linting
|
|
220
|
+
make lint # Run linting only
|
|
221
|
+
make test # Run tests only
|
|
222
|
+
make docs-serve # Preview documentation
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Requirements
|
|
226
|
+
|
|
227
|
+
- **Python**: 3.9+
|
|
228
|
+
- **NetGraph-Core**: Compatible C++ backend version
|
|
229
|
+
|
|
230
|
+
## Documentation
|
|
231
|
+
|
|
232
|
+
- **Site**: [networmix.github.io/NetGraph](https://networmix.github.io/NetGraph/)
|
|
233
|
+
- **Tutorial**: [Getting Started](https://networmix.github.io/NetGraph/getting-started/tutorial/)
|
|
234
|
+
- **Reference**: [API](https://networmix.github.io/NetGraph/reference/api/) | [CLI](https://networmix.github.io/NetGraph/reference/cli/) | [DSL](https://networmix.github.io/NetGraph/reference/dsl/)
|
|
235
|
+
|
|
236
|
+
## License
|
|
237
|
+
|
|
238
|
+
[GNU Affero General Public License v3.0 or later](LICENSE)
|
ngraph-0.12.2/README.md
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# NetGraph
|
|
2
|
+
|
|
3
|
+
[](https://github.com/networmix/NetGraph/actions/workflows/python-test.yml)
|
|
4
|
+
|
|
5
|
+
Scenario-driven network modeling and analysis framework combining Python's flexibility with high-performance C++ algorithms.
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
NetGraph enables declarative modeling of network topologies, traffic matrices, and failure scenarios. It delegates computationally intensive graph algorithms to [NetGraph-Core](https://github.com/networmix/NetGraph-Core) while providing a rich Python API and CLI for orchestration.
|
|
10
|
+
|
|
11
|
+
## Architecture
|
|
12
|
+
|
|
13
|
+
NetGraph employs a **hybrid Python+C++ architecture**:
|
|
14
|
+
|
|
15
|
+
- **Python layer (NetGraph)**: Scenario DSL parsing, workflow orchestration, result aggregation, and high-level APIs.
|
|
16
|
+
- **C++ layer (NetGraph-Core)**: Performance-critical graph algorithms (SPF, KSP, Max-Flow) executing in optimized C++ with the GIL released.
|
|
17
|
+
|
|
18
|
+
## Key Features
|
|
19
|
+
|
|
20
|
+
### 1. Modeling & DSL
|
|
21
|
+
|
|
22
|
+
- **Declarative Scenarios**: Define topology, traffic, and workflows in validated YAML.
|
|
23
|
+
- **Blueprints**: Reusable topology templates (e.g., Clos fabrics, regions) with parameterized expansion.
|
|
24
|
+
- **Strict Multigraph**: Deterministic graph representation with stable edge IDs.
|
|
25
|
+
|
|
26
|
+
### 2. Failure Analysis
|
|
27
|
+
|
|
28
|
+
- **Policy Engine**: Weighted failure modes with multiple policy rules per mode.
|
|
29
|
+
- **Non-Destructive**: Runtime exclusions simulate failures without modifying the base topology.
|
|
30
|
+
- **Risk Groups**: Model shared fate (e.g., fiber cuts, power zones).
|
|
31
|
+
|
|
32
|
+
### 3. Traffic Engineering
|
|
33
|
+
|
|
34
|
+
- **Routing Modes**: Unified modeling of **IP Routing** (static costs, oblivious to congestion) and **Traffic Engineering** (dynamic residuals, congestion-aware).
|
|
35
|
+
- **Flow Placement**: Strategies for **ECMP** (Equal-Cost Multi-Path) and **WCMP** (Weighted Cost Multi-Path).
|
|
36
|
+
- **Capacity Analysis**: Compute max-flow envelopes and demand allocation with configurable placement policies.
|
|
37
|
+
|
|
38
|
+
### 4. Workflow & Integration
|
|
39
|
+
|
|
40
|
+
- **Structured Results**: Export analysis artifacts to JSON for downstream processing.
|
|
41
|
+
- **CLI**: Comprehensive command-line interface for validation and execution.
|
|
42
|
+
- **Python API**: Full programmatic access to all modeling and solving capabilities.
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
### From PyPI
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install ngraph
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### From Source
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
git clone https://github.com/networmix/NetGraph
|
|
56
|
+
cd NetGraph
|
|
57
|
+
make dev # Install in editable mode with dev dependencies
|
|
58
|
+
make check # Run full test suite
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Quick Start
|
|
62
|
+
|
|
63
|
+
### CLI Usage
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Validate and inspect a scenario
|
|
67
|
+
ngraph inspect scenarios/backbone_clos.yml --detail
|
|
68
|
+
|
|
69
|
+
# Run analysis workflow
|
|
70
|
+
ngraph run scenarios/backbone_clos.yml --results clos.results.json
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Python API
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
from ngraph import Network, Node, Link, analyze, Mode
|
|
77
|
+
|
|
78
|
+
# Build network programmatically
|
|
79
|
+
network = Network()
|
|
80
|
+
network.add_node(Node("A"))
|
|
81
|
+
network.add_node(Node("B"))
|
|
82
|
+
network.add_node(Node("C"))
|
|
83
|
+
network.add_link(Link("A", "B", capacity=10.0, cost=1.0))
|
|
84
|
+
network.add_link(Link("B", "C", capacity=10.0, cost=1.0))
|
|
85
|
+
|
|
86
|
+
# Compute max flow with the analyze() API
|
|
87
|
+
flow = analyze(network).max_flow("^A$", "^C$", mode=Mode.COMBINE)
|
|
88
|
+
print(f"Max flow: {flow}") # {('^A$', '^C$'): 10.0}
|
|
89
|
+
|
|
90
|
+
# Efficient repeated analysis with bound context
|
|
91
|
+
ctx = analyze(network, source="^A$", sink="^C$", mode=Mode.COMBINE)
|
|
92
|
+
baseline = ctx.max_flow()
|
|
93
|
+
degraded = ctx.max_flow(excluded_nodes={"B"}) # Test failure scenario
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Example Scenario
|
|
97
|
+
|
|
98
|
+
NetGraph scenarios define topology, configuration, and analysis steps in a unified YAML file. This example demonstrates **blueprints** for modular topology definition:
|
|
99
|
+
|
|
100
|
+
```yaml
|
|
101
|
+
seed: 42
|
|
102
|
+
|
|
103
|
+
# Define reusable topology templates
|
|
104
|
+
blueprints:
|
|
105
|
+
Clos_Fabric:
|
|
106
|
+
groups:
|
|
107
|
+
spine: {node_count: 2, name_template: "spine{node_num}"}
|
|
108
|
+
leaf: {node_count: 4, name_template: "leaf{node_num}"}
|
|
109
|
+
adjacency:
|
|
110
|
+
- source: /leaf
|
|
111
|
+
target: /spine
|
|
112
|
+
pattern: mesh
|
|
113
|
+
link_params: {capacity: 100, cost: 1}
|
|
114
|
+
- source: /spine
|
|
115
|
+
target: /leaf
|
|
116
|
+
pattern: mesh
|
|
117
|
+
link_params: {capacity: 100, cost: 1}
|
|
118
|
+
|
|
119
|
+
# Instantiate network from templates
|
|
120
|
+
network:
|
|
121
|
+
groups:
|
|
122
|
+
site1: {use_blueprint: Clos_Fabric}
|
|
123
|
+
site2: {use_blueprint: Clos_Fabric}
|
|
124
|
+
adjacency:
|
|
125
|
+
- source: {path: site1/spine}
|
|
126
|
+
target: {path: site2/spine}
|
|
127
|
+
pattern: one_to_one
|
|
128
|
+
link_params: {capacity: 50, cost: 10}
|
|
129
|
+
|
|
130
|
+
# Define traffic matrix
|
|
131
|
+
traffic_matrix_set:
|
|
132
|
+
global_traffic:
|
|
133
|
+
- source_path: ^site1/leaf/
|
|
134
|
+
sink_path: ^site2/leaf/
|
|
135
|
+
demand: 100.0
|
|
136
|
+
mode: combine
|
|
137
|
+
flow_policy_config: SHORTEST_PATHS_ECMP
|
|
138
|
+
|
|
139
|
+
# Define analysis workflow
|
|
140
|
+
workflow:
|
|
141
|
+
- step_type: NetworkStats
|
|
142
|
+
name: stats
|
|
143
|
+
- step_type: MaxFlow
|
|
144
|
+
name: site_capacity
|
|
145
|
+
source_path: ^site1/leaf/
|
|
146
|
+
sink_path: ^site2/leaf/
|
|
147
|
+
mode: combine
|
|
148
|
+
shortest_path: false
|
|
149
|
+
- step_type: MaximumSupportedDemand
|
|
150
|
+
name: max_demand
|
|
151
|
+
matrix_name: global_traffic
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Repository Structure
|
|
155
|
+
|
|
156
|
+
```text
|
|
157
|
+
ngraph/ # Python package source
|
|
158
|
+
dsl/ # Scenario parsing and blueprint expansion
|
|
159
|
+
model/ # Network and flow domain models
|
|
160
|
+
solver/ # Algorithms and Core wrappers
|
|
161
|
+
workflow/ # Analysis steps and orchestration
|
|
162
|
+
scenarios/ # Example scenario definitions
|
|
163
|
+
tests/ # Pytest suite (unit and integration)
|
|
164
|
+
docs/ # Documentation source (MkDocs)
|
|
165
|
+
dev/ # Development tools and scripts
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Development
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
make dev # Setup environment
|
|
172
|
+
make check # Run tests and linting
|
|
173
|
+
make lint # Run linting only
|
|
174
|
+
make test # Run tests only
|
|
175
|
+
make docs-serve # Preview documentation
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Requirements
|
|
179
|
+
|
|
180
|
+
- **Python**: 3.9+
|
|
181
|
+
- **NetGraph-Core**: Compatible C++ backend version
|
|
182
|
+
|
|
183
|
+
## Documentation
|
|
184
|
+
|
|
185
|
+
- **Site**: [networmix.github.io/NetGraph](https://networmix.github.io/NetGraph/)
|
|
186
|
+
- **Tutorial**: [Getting Started](https://networmix.github.io/NetGraph/getting-started/tutorial/)
|
|
187
|
+
- **Reference**: [API](https://networmix.github.io/NetGraph/reference/api/) | [CLI](https://networmix.github.io/NetGraph/reference/cli/) | [DSL](https://networmix.github.io/NetGraph/reference/dsl/)
|
|
188
|
+
|
|
189
|
+
## License
|
|
190
|
+
|
|
191
|
+
[GNU Affero General Public License v3.0 or later](LICENSE)
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"""NetGraph: Network modeling and analysis library.
|
|
2
|
+
|
|
3
|
+
NetGraph provides interfaces for network topology modeling, traffic analysis, and
|
|
4
|
+
capacity planning using a hybrid Python+C++ architecture.
|
|
5
|
+
|
|
6
|
+
Primary API:
|
|
7
|
+
analyze() - Create an analysis context for network queries
|
|
8
|
+
AnalysisContext - Prepared state for efficient repeated analysis
|
|
9
|
+
Network, Node, Link - Network topology model
|
|
10
|
+
from_networkx() - Convert NetworkX graph to internal format
|
|
11
|
+
to_networkx() - Convert internal format back to NetworkX
|
|
12
|
+
|
|
13
|
+
Example:
|
|
14
|
+
from ngraph import Network, Node, Link, analyze
|
|
15
|
+
|
|
16
|
+
# Build network
|
|
17
|
+
net = Network()
|
|
18
|
+
net.add_node(Node(name="A"))
|
|
19
|
+
net.add_node(Node(name="B"))
|
|
20
|
+
net.add_link(Link(source="A", target="B", capacity=100.0))
|
|
21
|
+
|
|
22
|
+
# One-off analysis
|
|
23
|
+
flow = analyze(net).max_flow("^A$", "^B$")
|
|
24
|
+
|
|
25
|
+
# Efficient repeated analysis
|
|
26
|
+
ctx = analyze(net, source="^A$", sink="^B$")
|
|
27
|
+
baseline = ctx.max_flow()
|
|
28
|
+
degraded = ctx.max_flow(excluded_links=failed_links)
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
from __future__ import annotations
|
|
32
|
+
|
|
33
|
+
from ngraph import cli, logging
|
|
34
|
+
from ngraph._version import __version__
|
|
35
|
+
from ngraph.analysis import AnalysisContext, analyze
|
|
36
|
+
from ngraph.exec.failure.manager import FailureManager
|
|
37
|
+
from ngraph.lib.nx import EdgeMap, NodeMap, from_networkx, to_networkx
|
|
38
|
+
from ngraph.model.demand.matrix import TrafficMatrixSet
|
|
39
|
+
from ngraph.model.network import Link, Network, Node, RiskGroup
|
|
40
|
+
from ngraph.model.path import Path
|
|
41
|
+
from ngraph.results.artifacts import CapacityEnvelope
|
|
42
|
+
from ngraph.results.flow import FlowEntry, FlowIterationResult, FlowSummary
|
|
43
|
+
from ngraph.types.base import EdgeSelect, FlowPlacement, Mode
|
|
44
|
+
from ngraph.types.dto import EdgeRef, MaxFlowResult
|
|
45
|
+
|
|
46
|
+
__all__ = [
|
|
47
|
+
# Version
|
|
48
|
+
"__version__",
|
|
49
|
+
# Model
|
|
50
|
+
"Network",
|
|
51
|
+
"Node",
|
|
52
|
+
"Link",
|
|
53
|
+
"RiskGroup",
|
|
54
|
+
"Path",
|
|
55
|
+
"TrafficMatrixSet",
|
|
56
|
+
# Analysis (primary API)
|
|
57
|
+
"analyze",
|
|
58
|
+
"AnalysisContext",
|
|
59
|
+
# Types
|
|
60
|
+
"FlowPlacement",
|
|
61
|
+
"EdgeSelect",
|
|
62
|
+
"Mode",
|
|
63
|
+
"EdgeRef",
|
|
64
|
+
"MaxFlowResult",
|
|
65
|
+
# Results
|
|
66
|
+
"FlowEntry",
|
|
67
|
+
"FlowIterationResult",
|
|
68
|
+
"FlowSummary",
|
|
69
|
+
"CapacityEnvelope",
|
|
70
|
+
# Execution
|
|
71
|
+
"FailureManager",
|
|
72
|
+
# Library integrations (NetworkX)
|
|
73
|
+
"EdgeMap",
|
|
74
|
+
"NodeMap",
|
|
75
|
+
"from_networkx",
|
|
76
|
+
"to_networkx",
|
|
77
|
+
# Utilities
|
|
78
|
+
"cli",
|
|
79
|
+
"logging",
|
|
80
|
+
]
|