|
6 | 6 |
|
7 | 7 | - [Introduction](#introduction) |
8 | 8 | - [Installation and Usage](#installation-and-usage) |
9 | | - - [Using the Docker Container with JupyterLab](#1-using-the-docker-container-with-jupyter-notebooks) |
| 9 | + - [Using the Docker Container with JupyterLab](#1-using-the-docker-container-with-jupyterlab) |
10 | 10 | - [Using the Python Package](#2-using-the-python-package) |
11 | 11 | - [Use Case Examples](#use-case-examples) |
12 | 12 | - [Calculate MaxFlow in a graph](#calculate-maxflow-in-a-graph) |
13 | | - - [Place traffic demands on a graph](#place-traffic-demands-on-a-graph) |
14 | | - - [Perform basic capacity analysis](#perform-basic-capacity-analysis) |
| 13 | + - [Traffic demands placement on a graph](#traffic-demands-placement-on-a-graph) |
15 | 14 |
|
16 | 15 | --- |
17 | 16 |
|
@@ -111,26 +110,23 @@ Note: Don't forget to use a virtual environment (e.g., `venv`) to avoid conflict |
111 | 110 | 2. Use the package in your Python code: |
112 | 111 |
|
113 | 112 | ```python |
114 | | - from ngraph.lib.graph import StrictMultiDiGraph |
115 | | - from ngraph.lib.max_flow import calc_max_flow |
116 | | -
|
117 | | - # Create a graph |
118 | | - g = StrictMultiDiGraph() |
119 | | - g.add_node("A") |
120 | | - g.add_node("B") |
121 | | - g.add_node("C") |
122 | | - g.add_node("D") |
123 | | - g.add_edge("A", "B", metric=1, capacity=1) |
124 | | - g.add_edge("B", "C", metric=1, capacity=1) |
125 | | - g.add_edge("A", "B", metric=1, capacity=2) |
126 | | - g.add_edge("B", "C", metric=1, capacity=2) |
127 | | - g.add_edge("A", "D", metric=2, capacity=3) |
128 | | - g.add_edge("D", "C", metric=2, capacity=3) |
129 | | -
|
130 | | - # Calculate MaxFlow between the source and destination nodes |
131 | | - max_flow = calc_max_flow(g, "A", "C") |
132 | | -
|
133 | | - print(max_flow) |
| 113 | + from ngraph.lib.graph import StrictMultiDiGraph |
| 114 | + from ngraph.lib.algorithms.max_flow import calc_max_flow |
| 115 | +
|
| 116 | + # Create a graph |
| 117 | + g = StrictMultiDiGraph() |
| 118 | + g.add_node("A") |
| 119 | + g.add_node("B") |
| 120 | + g.add_node("C") |
| 121 | + g.add_edge("A", "B", metric=1, capacity=1) |
| 122 | + g.add_edge("A", "B", metric=1, capacity=1) |
| 123 | + g.add_edge("B", "C", metric=1, capacity=2) |
| 124 | + g.add_edge("A", "C", metric=2, capacity=3) |
| 125 | +
|
| 126 | + # Calculate MaxFlow between the source and destination nodes |
| 127 | + max_flow = calc_max_flow(g, "A", "C") |
| 128 | +
|
| 129 | + print(max_flow) |
134 | 130 | ``` |
135 | 131 |
|
136 | 132 | ## Use Case Examples |
|
0 commit comments