From 8d28ef44be0c669a70615389b92226dfe619ddbd Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sat, 29 Mar 2025 16:51:09 +0100 Subject: [PATCH] WIP: add tests --- tests/example_flows.rs | 25 +++++++++++++++++++++++++ tests/valid_flow.rs | 2 ++ 2 files changed, 27 insertions(+) create mode 100644 tests/example_flows.rs create mode 100644 tests/valid_flow.rs diff --git a/tests/example_flows.rs b/tests/example_flows.rs new file mode 100644 index 0000000..a9b8c73 --- /dev/null +++ b/tests/example_flows.rs @@ -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: +} diff --git a/tests/valid_flow.rs b/tests/valid_flow.rs new file mode 100644 index 0000000..10342a3 --- /dev/null +++ b/tests/valid_flow.rs @@ -0,0 +1,2 @@ +// check capacity at each edge (incoming flows = outgoing flows) +// check capacity isn't violated (flow <= capacity) \ No newline at end of file