Skip to content

Commit 4aa2c56

Browse files
committed
Update README.md
1 parent fa5ce38 commit 4aa2c56

1 file changed

Lines changed: 28 additions & 12 deletions

File tree

README.md

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ pip install ngraph
7272
```bash
7373
git clone https://github.com/networmix/NetGraph
7474
cd NetGraph
75-
python -m venv venv
76-
source venv/bin/activate # On Windows: venv\Scripts\activate
77-
pip install -e '.[dev]'
75+
make dev # install in editable mode
76+
make check # run all checks
7877
```
7978

8079
### CLI
@@ -87,24 +86,41 @@ ngraph inspect scenarios/backbone_clos.yml --detail
8786
ngraph run scenarios/backbone_clos.yml --results clos.results.json
8887
```
8988

90-
### Python API (minimal)
89+
### Python API (MaxFlow quick demo)
9190

9291
```python
9392
from ngraph.scenario import Scenario
93+
from ngraph.algorithms.base import FlowPlacement
9494

9595
scenario_yaml = """
96-
seed: 1
96+
seed: 1234
9797
network:
98-
nodes: {A: {}, B: {}}
98+
nodes: {A: {}, B: {}, C: {}, D: {}}
9999
links:
100-
- {source: A, target: B, link_params: {capacity: 10.0, cost: 1.0}}
101-
workflow:
102-
- {step_type: NetworkStats, name: baseline_stats}
100+
- {source: A, target: B, link_params: {capacity: 1, cost: 1}}
101+
- {source: A, target: B, link_params: {capacity: 2, cost: 1}}
102+
- {source: B, target: C, link_params: {capacity: 1, cost: 1}}
103+
- {source: B, target: C, link_params: {capacity: 2, cost: 1}}
104+
- {source: A, target: D, link_params: {capacity: 3, cost: 2}}
105+
- {source: D, target: C, link_params: {capacity: 3, cost: 2}}
103106
"""
104-
105107
scenario = Scenario.from_yaml(scenario_yaml)
106-
scenario.run()
107-
print(list(scenario.results.to_dict()["steps"].keys()))
108+
network = scenario.network
109+
110+
print(network.max_flow("A", "C")) # {('A', 'C'): 6.0}
111+
print(network.max_flow("A", "C", shortest_path=True)) # {('A', 'C'): 3.0}
112+
print(
113+
network.max_flow(
114+
"A",
115+
"C",
116+
shortest_path=True,
117+
flow_placement=FlowPlacement.EQUAL_BALANCED,
118+
)
119+
) # {('A', 'C'): 2.0}
120+
121+
res = network.max_flow_with_summary("A", "C")
122+
print({k: (v[0], v[1].cost_distribution) for k, v in res.items()})
123+
# {('A', 'C'): (6.0, {2.0: 3.0, 4.0: 3.0})}
108124
```
109125

110126
## Documentation

0 commit comments

Comments
 (0)