WIP: add tests
This commit is contained in:
25
tests/example_flows.rs
Normal file
25
tests/example_flows.rs
Normal 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:
|
||||||
|
}
|
||||||
2
tests/valid_flow.rs
Normal file
2
tests/valid_flow.rs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
// check capacity at each edge (incoming flows = outgoing flows)
|
||||||
|
// check capacity isn't violated (flow <= capacity)
|
||||||
Reference in New Issue
Block a user