Skip to content

Commit 34fa549

Browse files
committed
updating readme and notebook examples
1 parent 05edd0f commit 34fa549

File tree

2 files changed

+55
-23
lines changed

2 files changed

+55
-23
lines changed

README.md

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66

77
- [Introduction](#introduction)
88
- [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)
1010
- [Using the Python Package](#2-using-the-python-package)
1111
- [Use Case Examples](#use-case-examples)
1212
- [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)
1514

1615
---
1716

@@ -111,26 +110,23 @@ Note: Don't forget to use a virtual environment (e.g., `venv`) to avoid conflict
111110
2. Use the package in your Python code:
112111
113112
```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)
134130
```
135131
136132
## Use Case Examples

notebooks/lib_examples.ipynb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,42 @@
99
"This notebook contains examples of using the NetGraph library to create and manipulate graphs, calculate maximum flow, and place traffic demands."
1010
]
1111
},
12+
{
13+
"cell_type": "code",
14+
"execution_count": 1,
15+
"metadata": {},
16+
"outputs": [
17+
{
18+
"name": "stdout",
19+
"output_type": "stream",
20+
"text": [
21+
"6.0\n"
22+
]
23+
}
24+
],
25+
"source": [
26+
"from ngraph.lib.graph import StrictMultiDiGraph\n",
27+
"from ngraph.lib.algorithms.max_flow import calc_max_flow\n",
28+
"\n",
29+
"# Create a graph\n",
30+
"g = StrictMultiDiGraph()\n",
31+
"g.add_node(\"A\")\n",
32+
"g.add_node(\"B\")\n",
33+
"g.add_node(\"C\")\n",
34+
"g.add_node(\"D\")\n",
35+
"g.add_edge(\"A\", \"B\", metric=1, capacity=1)\n",
36+
"g.add_edge(\"B\", \"C\", metric=1, capacity=1)\n",
37+
"g.add_edge(\"A\", \"B\", metric=1, capacity=2)\n",
38+
"g.add_edge(\"B\", \"C\", metric=1, capacity=2)\n",
39+
"g.add_edge(\"A\", \"D\", metric=2, capacity=3)\n",
40+
"g.add_edge(\"D\", \"C\", metric=2, capacity=3)\n",
41+
"\n",
42+
"# Calculate MaxFlow between the source and destination nodes\n",
43+
"max_flow = calc_max_flow(g, \"A\", \"C\")\n",
44+
"\n",
45+
"print(max_flow)"
46+
]
47+
},
1248
{
1349
"cell_type": "code",
1450
"execution_count": 3,

0 commit comments

Comments
 (0)