WIP: add tests

This commit is contained in:
2025-03-29 16:51:09 +01:00
parent a13c1a5001
commit 8d28ef44be
2 changed files with 27 additions and 0 deletions

25
tests/example_flows.rs Normal file
View File

@@ -0,0 +1,25 @@
use petgraph::prelude::StableGraph;
// Example taken from: https://en.wikipedia.org/wiki/Dinic%27s_algorithm#Example
#[test]
fn test_maxflow_small_graph() {
let mut g: StableGraph<(f32, f32), (u64, u64)> = StableGraph::new();
let s = g.add_node((0., 5.));
let one = g.add_node((10., 0.));
let two = g.add_node((10., 10.));
let three = g.add_node((20., 0.));
let four = g.add_node((20., 10.));
let t = g.add_node((30., 5.));
g.add_edge(s, one, (0, 10));
g.add_edge(s, two, (0, 10));
g.add_edge(one, three, (0, 4));
g.add_edge(one, four, (0, 8));
g.add_edge(one, two, (0,2));
g.add_edge(two, four, (0,9));
g.add_edge(three, t, (0,10));
g.add_edge(four, three, (0,6));
g.add_edge(four, t, (0,10));
// TODO:
}