src/work/marci/edmonds_karp_demo.cc
changeset 311 6635b11938fe
parent 305 6720705c9095
child 317 6e6db1c49bc1
     1.1 --- a/src/work/marci/edmonds_karp_demo.cc	Mon Apr 05 18:24:37 2004 +0000
     1.2 +++ b/src/work/marci/edmonds_karp_demo.cc	Tue Apr 06 12:00:34 2004 +0000
     1.3 @@ -8,11 +8,7 @@
     1.4  #include <edmonds_karp.h>
     1.5  #include <time_measure.h>
     1.6  //#include <graph_wrapper.h>
     1.7 -
     1.8 -class CM {
     1.9 -public:
    1.10 -  template<typename T> int get(T) const {return 1;}
    1.11 -};
    1.12 +#include <preflow.h>
    1.13  
    1.14  using namespace hugo;
    1.15  
    1.16 @@ -88,9 +84,37 @@
    1.17  //   //cgw.erase(csw);
    1.18  //   std::cout << "p2:" << cgw.nodeNum() << std::endl;
    1.19  
    1.20 +  {
    1.21 +    std::cout << "preflow ..." << std::endl;
    1.22 +    Graph::EdgeMap<int> flow(G); //0 flow
    1.23 +
    1.24 +    Timer ts;
    1.25 +    ts.reset();
    1.26 +
    1.27 +    Preflow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
    1.28 +      max_flow_test(G, s, t, cap, flow);
    1.29 +    max_flow_test.run();
    1.30 +//    int i=0;
    1.31 +//    while (max_flow_test.augmentOnBlockingFlow<MutableGraph>()) { 
    1.32 +//     for(EdgeIt e=G.template first<EdgeIt>(); e.valid(); ++e) { 
    1.33 +//       std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
    1.34 +//     }
    1.35 +//     std::cout<<std::endl;
    1.36 +//      ++i; 
    1.37 +//    }
    1.38 +
    1.39 +//   std::cout << "maximum flow: "<< std::endl;
    1.40 +//   for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) { 
    1.41 +//     std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
    1.42 +//   }
    1.43 +//   std::cout<<std::endl;
    1.44 +    std::cout << "elapsed time: " << ts << std::endl;
    1.45 +//    std::cout << "number of augmentation phases: " << i << std::endl; 
    1.46 +    std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
    1.47 +  }
    1.48  
    1.49    {
    1.50 -    std::cout << "edmonds karp demo (physical blocking flow augmentation)..." << std::endl;
    1.51 +    std::cout << "physical blocking flow augmentation ..." << std::endl;
    1.52      Graph::EdgeMap<int> flow(G); //0 flow
    1.53  
    1.54      Timer ts;
    1.55 @@ -118,7 +142,7 @@
    1.56    }
    1.57  
    1.58    {
    1.59 -    std::cout << "edmonds karp demo (physical blocking flow 1 augmentation)..." << std::endl;
    1.60 +    std::cout << "faster physical blocking flow augmentation ..." << std::endl;
    1.61      Graph::EdgeMap<int> flow(G); //0 flow
    1.62  
    1.63      Timer ts;
    1.64 @@ -146,7 +170,7 @@
    1.65    }
    1.66  
    1.67    {
    1.68 -    std::cout << "edmonds karp demo (on-the-fly blocking flow augmentation)..." << std::endl;
    1.69 +    std::cout << "on-the-fly blocking flow augmentation ..." << std::endl;
    1.70      Graph::EdgeMap<int> flow(G); //0 flow
    1.71  
    1.72      Timer ts;
    1.73 @@ -174,7 +198,7 @@
    1.74    }
    1.75  
    1.76    {
    1.77 -    std::cout << "edmonds karp demo (on-the-fly shortest path augmentation)..." << std::endl;
    1.78 +    std::cout << "on-the-fly shortest path augmentation ..." << std::endl;
    1.79      Graph::EdgeMap<int> flow(G); //0 flow
    1.80  
    1.81      Timer ts;