test/preflow_test.cc
branch1.1
changeset 1028 075de3c84e1f
parent 632 65fbcf2f978a
child 1029 79fab87ee483
child 1081 f1398882a928
child 1171 7e368d9b67f7
     1.1 --- a/test/preflow_test.cc	Wed Sep 22 09:26:01 2010 +0200
     1.2 +++ b/test/preflow_test.cc	Mon Feb 28 09:50:33 2011 +0100
     1.3 @@ -151,6 +151,30 @@
     1.4    return true;
     1.5  }
     1.6  
     1.7 +void initFlowTest()
     1.8 +{
     1.9 +  DIGRAPH_TYPEDEFS(SmartDigraph);
    1.10 +  
    1.11 +  SmartDigraph g;
    1.12 +  SmartDigraph::ArcMap<int> cap(g),iflow(g);
    1.13 +  Node s=g.addNode(); Node t=g.addNode();
    1.14 +  Node n1=g.addNode(); Node n2=g.addNode();
    1.15 +  Arc a;
    1.16 +  a=g.addArc(s,n1); cap[a]=20; iflow[a]=20;
    1.17 +  a=g.addArc(n1,n2); cap[a]=10; iflow[a]=0;
    1.18 +  a=g.addArc(n2,t); cap[a]=20; iflow[a]=0;
    1.19 +
    1.20 +  Preflow<SmartDigraph> pre(g,cap,s,t);
    1.21 +  pre.init(iflow);
    1.22 +  pre.startFirstPhase();
    1.23 +  check(pre.flowValue() == 10, "The incorrect max flow value.");
    1.24 +  check(pre.minCut(s), "Wrong min cut (Node s).");
    1.25 +  check(pre.minCut(n1), "Wrong min cut (Node n1).");
    1.26 +  check(!pre.minCut(n2), "Wrong min cut (Node n2).");
    1.27 +  check(!pre.minCut(t), "Wrong min cut (Node t).");
    1.28 +}
    1.29 +
    1.30 +
    1.31  int main() {
    1.32  
    1.33    typedef SmartDigraph Digraph;
    1.34 @@ -241,5 +265,7 @@
    1.35    check(preflow_test.flowValue() == min_cut_value,
    1.36          "The max flow value or the three min cut values are incorrect.");
    1.37  
    1.38 +  initFlowTest();
    1.39 +  
    1.40    return 0;
    1.41  }