src/test/min_cost_flow_test.cc
changeset 941 186aa53d2802
parent 921 818510fa3d99
child 1164 80bb73097736
     1.1 --- a/src/test/min_cost_flow_test.cc	Thu Oct 07 17:21:27 2004 +0000
     1.2 +++ b/src/test/min_cost_flow_test.cc	Fri Oct 08 13:07:51 2004 +0000
     1.3 @@ -21,11 +21,9 @@
     1.4  //#include <path.h>
     1.5  //#include <maps.h>
     1.6  
     1.7 -using namespace std;
     1.8  using namespace lemon;
     1.9  
    1.10  
    1.11 -
    1.12  bool passed = true;
    1.13  /*
    1.14  void check(bool rc, char *msg="") {
    1.15 @@ -41,11 +39,11 @@
    1.16  
    1.17  int main()
    1.18  {
    1.19 +  typedef ListGraph Graph;
    1.20 +  typedef Graph::Node Node;
    1.21 +  typedef Graph::Edge Edge;
    1.22  
    1.23 -  typedef ListGraph::Node Node;
    1.24 -  typedef ListGraph::Edge Edge;
    1.25 -
    1.26 -  ListGraph graph;
    1.27 +  Graph graph;
    1.28  
    1.29    //Ahuja könyv példája
    1.30  
    1.31 @@ -67,7 +65,7 @@
    1.32    Edge v5_t=graph.addEdge(v5, t);
    1.33    
    1.34  
    1.35 -  ListGraph::EdgeMap<int> length(graph);
    1.36 +  Graph::EdgeMap<int> length(graph);
    1.37  
    1.38    length.set(s_v1, 6);
    1.39    length.set(v1_v2, 4);
    1.40 @@ -78,7 +76,7 @@
    1.41    length.set(v4_t, 8);
    1.42    length.set(v5_t, 8);
    1.43  
    1.44 -  ListGraph::EdgeMap<int> capacity(graph);
    1.45 +  Graph::EdgeMap<int> capacity(graph);
    1.46  
    1.47    capacity.set(s_v1, 2);
    1.48    capacity.set(v1_v2, 2);
    1.49 @@ -92,31 +90,36 @@
    1.50    //  ConstMap<Edge, int> const1map(1);
    1.51    std::cout << "Mincostflows algorithm test..." << std::endl;
    1.52  
    1.53 -  MinCostFlow< ListGraph, ListGraph::EdgeMap<int>, ListGraph::EdgeMap<int> >
    1.54 -    surb_test(graph, length, capacity);
    1.55 +  MinCostFlow< Graph, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
    1.56 +    surb_test(graph, length, capacity, s, t);
    1.57  
    1.58    int k=1;
    1.59  
    1.60 -  check(  surb_test.run(s,t,k) == 1 && surb_test.totalLength() == 19,"One path, total length should be 19");
    1.61 +  surb_test.augment();
    1.62 +  check(  surb_test.flowValue() == 1 && surb_test.totalLength() == 19,"One path, total length should be 19");
    1.63 +
    1.64 +  check(  surb_test.run(k) == 1 && surb_test.totalLength() == 19,"One path, total length should be 19");
    1.65  
    1.66    check(surb_test.checkComplementarySlackness(), "Is the primal-dual solution pair really optimal?");
    1.67    
    1.68    k=2;
    1.69    
    1.70 -  check(  surb_test.run(s,t,k) == 2 && surb_test.totalLength() == 41,"Two paths, total length should be 41");
    1.71 +  check(  surb_test.run(k) == 2 && surb_test.totalLength() == 41,"Two paths, total length should be 41");
    1.72  
    1.73    check(surb_test.checkComplementarySlackness(), "Is the primal-dual solution pair really optimal?");
    1.74    
    1.75 -  
    1.76 +  surb_test.augment();
    1.77 +  surb_test.augment();
    1.78 +  surb_test.augment();
    1.79    k=4;
    1.80  
    1.81 -  check(  surb_test.run(s,t,k) == 3 && surb_test.totalLength() == 64,"Three paths, total length should be 64");
    1.82 +  check(  surb_test.run(k) == 3 && surb_test.totalLength() == 64,"Three paths, total length should be 64");
    1.83  
    1.84    check(surb_test.checkComplementarySlackness(), "Is the primal-dual solution pair really optimal?");
    1.85  
    1.86  
    1.87 -  cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
    1.88 -       << endl;
    1.89 +  std::cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
    1.90 +	    << std::endl;
    1.91  
    1.92    return passed ? 0 : 1;
    1.93