src/work/marci/lg_vs_sg_vs_sg.cc
changeset 1365 c280de819a73
parent 1364 ee5959aa4410
child 1366 d00b85f8be45
     1.1 --- a/src/work/marci/lg_vs_sg_vs_sg.cc	Sun Apr 17 18:57:22 2005 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,254 +0,0 @@
     1.4 -// -*- c++ -*-
     1.5 -#include <iostream>
     1.6 -#include <fstream>
     1.7 -#include <string>
     1.8 -
     1.9 -#include <sage_graph.h>
    1.10 -#include <lemon/list_graph.h>
    1.11 -#include <lemon/smart_graph.h>
    1.12 -#include <lemon/dimacs.h>
    1.13 -#include <lemon/max_flow.h>
    1.14 -#include <augmenting_flow.h>
    1.15 -#include <lemon/time_measure.h>
    1.16 -#include <for_each_macros.h>
    1.17 -
    1.18 -using namespace lemon;
    1.19 -
    1.20 -// Use a DIMACS max flow file as stdin.
    1.21 -// read_dimacs_demo dimacs_max_flow_file
    1.22 -
    1.23 -int main(int, char** argv) {
    1.24 -
    1.25 -  std::string in=argv[1];
    1.26 -  typedef SageGraph MutableGraph;
    1.27 -
    1.28 -  {
    1.29 -    typedef SageGraph Graph;
    1.30 -    typedef Graph::Node Node;
    1.31 -    typedef Graph::EdgeIt EdgeIt;
    1.32 -
    1.33 -    Graph g;
    1.34 -    Node s, t;
    1.35 -    Graph::EdgeMap<int> cap(g);
    1.36 -    std::ifstream ins(in.c_str());
    1.37 -    //readDimacsMaxFlow(ins, g, s, t, cap);
    1.38 -    readDimacs(ins, g, cap, s, t);
    1.39 -
    1.40 -    Timer ts;
    1.41 -    Graph::EdgeMap<int> flow(g); //0 flow
    1.42 -    MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
    1.43 -      max_flow_test(g, s, t, cap, flow/*, true*/);
    1.44 -    AugmentingFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
    1.45 -      augmenting_flow_test(g, s, t, cap, flow/*, true*/);
    1.46 -
    1.47 -    std::cout << "SageGraph ..." << std::endl;
    1.48 -
    1.49 -    {
    1.50 -      std::cout << "preflow ..." << std::endl;
    1.51 -      ts.reset();
    1.52 -      max_flow_test.run();
    1.53 -      std::cout << "elapsed time: " << ts << std::endl;
    1.54 -      std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
    1.55 -    }
    1.56 -
    1.57 -    {
    1.58 -      std::cout << "physical blocking flow augmentation ..." << std::endl;
    1.59 -      for (Graph::EdgeIt e(g); e!=INVALID; ++e) flow.set(e, 0);
    1.60 -      ts.reset();
    1.61 -      int i=0;
    1.62 -      while (augmenting_flow_test.augmentOnBlockingFlow<MutableGraph>()) { ++i; }
    1.63 -      std::cout << "elapsed time: " << ts << std::endl;
    1.64 -      std::cout << "number of augmentation phases: " << i << std::endl; 
    1.65 -      std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
    1.66 -    }
    1.67 -
    1.68 -//     {
    1.69 -//       std::cout << "faster physical blocking flow augmentation ..." << std::endl;
    1.70 -//       FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
    1.71 -//       ts.reset();
    1.72 -//       int i=0;
    1.73 -//       while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) { ++i; }
    1.74 -//       std::cout << "elapsed time: " << ts << std::endl;
    1.75 -//       std::cout << "number of augmentation phases: " << i << std::endl; 
    1.76 -//       std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
    1.77 -//     }
    1.78 -
    1.79 -    {
    1.80 -      std::cout << "on-the-fly blocking flow augmentation ..." << std::endl;
    1.81 -      for (Graph::EdgeIt e(g); e!=INVALID; ++e) flow.set(e, 0);
    1.82 -      ts.reset();
    1.83 -      int i=0;
    1.84 -      while (augmenting_flow_test.augmentOnBlockingFlow2()) { ++i; }
    1.85 -      std::cout << "elapsed time: " << ts << std::endl;
    1.86 -      std::cout << "number of augmentation phases: " << i << std::endl; 
    1.87 -      std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
    1.88 -    }
    1.89 -
    1.90 -    {
    1.91 -      std::cout << "on-the-fly shortest path augmentation ..." << std::endl;
    1.92 -      for (Graph::EdgeIt e(g); e!=INVALID; ++e) flow.set(e, 0);
    1.93 -      ts.reset();
    1.94 -      int i=0;
    1.95 -      while (augmenting_flow_test.augmentOnShortestPath()) { ++i; }
    1.96 -      std::cout << "elapsed time: " << ts << std::endl;
    1.97 -      std::cout << "number of augmentation phases: " << i << std::endl; 
    1.98 -      std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
    1.99 -    }
   1.100 -  }
   1.101 -
   1.102 -  {
   1.103 -    typedef SmartGraph Graph;
   1.104 -    typedef Graph::Node Node;
   1.105 -    typedef Graph::EdgeIt EdgeIt;
   1.106 -
   1.107 -    Graph g;
   1.108 -    Node s, t;
   1.109 -    Graph::EdgeMap<int> cap(g);
   1.110 -    std::ifstream ins(in.c_str());
   1.111 -    //readDimacsMaxFlow(ins, g, s, t, cap);
   1.112 -    readDimacs(ins, g, cap, s, t);
   1.113 -
   1.114 -    Timer ts;
   1.115 -    Graph::EdgeMap<int> flow(g); //0 flow
   1.116 -    MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
   1.117 -      max_flow_test(g, s, t, cap, flow/*, true*/);
   1.118 -    AugmentingFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
   1.119 -      augmenting_flow_test(g, s, t, cap, flow/*, true*/);
   1.120 -    //    MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
   1.121 -    //  max_flow_test(g, s, t, cap, flow);
   1.122 -
   1.123 -    std::cout << "SmartGraph ..." << std::endl;
   1.124 -
   1.125 -    {
   1.126 -      std::cout << "preflow ..." << std::endl;
   1.127 -      for (Graph::EdgeIt e(g); e!=INVALID; ++e) flow.set(e, 0);
   1.128 -      ts.reset();
   1.129 -      max_flow_test.run();
   1.130 -      std::cout << "elapsed time: " << ts << std::endl;
   1.131 -      std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
   1.132 -    }
   1.133 -
   1.134 -    {
   1.135 -      std::cout << "physical blocking flow augmentation ..." << std::endl;
   1.136 -      for (Graph::EdgeIt e(g); e!=INVALID; ++e) flow.set(e, 0);
   1.137 -      ts.reset();
   1.138 -      int i=0;
   1.139 -      while (augmenting_flow_test.augmentOnBlockingFlow<MutableGraph>()) { ++i; }
   1.140 -      std::cout << "elapsed time: " << ts << std::endl;
   1.141 -      std::cout << "number of augmentation phases: " << i << std::endl; 
   1.142 -      std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
   1.143 -    }
   1.144 -
   1.145 -//     {
   1.146 -//       std::cout << "faster physical blocking flow augmentation ..." << std::endl;
   1.147 -//       FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
   1.148 -//       ts.reset();
   1.149 -//       int i=0;
   1.150 -//       while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) { ++i; }
   1.151 -//       std::cout << "elapsed time: " << ts << std::endl;
   1.152 -//       std::cout << "number of augmentation phases: " << i << std::endl; 
   1.153 -//       std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
   1.154 -//     }
   1.155 -
   1.156 -    {
   1.157 -      std::cout << "on-the-fly blocking flow augmentation ..." << std::endl;
   1.158 -      for (Graph::EdgeIt e(g); e!=INVALID; ++e) flow.set(e, 0);
   1.159 -      ts.reset();
   1.160 -      int i=0;
   1.161 -      while (augmenting_flow_test.augmentOnBlockingFlow2()) { ++i; }
   1.162 -      std::cout << "elapsed time: " << ts << std::endl;
   1.163 -      std::cout << "number of augmentation phases: " << i << std::endl; 
   1.164 -      std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
   1.165 -    }
   1.166 -
   1.167 -    {
   1.168 -      std::cout << "on-the-fly shortest path augmentation ..." << std::endl;
   1.169 -      for (Graph::EdgeIt e(g); e!=INVALID; ++e) flow.set(e, 0);
   1.170 -      ts.reset();
   1.171 -      int i=0;
   1.172 -      while (augmenting_flow_test.augmentOnShortestPath()) { ++i; }
   1.173 -      std::cout << "elapsed time: " << ts << std::endl;
   1.174 -      std::cout << "number of augmentation phases: " << i << std::endl; 
   1.175 -      std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
   1.176 -    }
   1.177 -  }
   1.178 -
   1.179 -  {
   1.180 -    typedef ListGraph Graph;
   1.181 -    typedef Graph::Node Node;
   1.182 -    typedef Graph::EdgeIt EdgeIt;
   1.183 -
   1.184 -    Graph g;
   1.185 -    Node s, t;
   1.186 -    Graph::EdgeMap<int> cap(g);
   1.187 -    std::ifstream ins(in.c_str());
   1.188 -    //readDimacsMaxFlow(ins, g, s, t, cap);
   1.189 -    readDimacs(ins, g, cap, s, t);
   1.190 -
   1.191 -    Timer ts;
   1.192 -    Graph::EdgeMap<int> flow(g); //0 flow
   1.193 -    MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
   1.194 -      max_flow_test(g, s, t, cap, flow/*, true*/);
   1.195 -    AugmentingFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
   1.196 -      augmenting_flow_test(g, s, t, cap, flow/*, true*/);
   1.197 -    //    MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
   1.198 -    //  max_flow_test(g, s, t, cap, flow);
   1.199 -
   1.200 -    std::cout << "ListGraph ..." << std::endl;
   1.201 -
   1.202 -    {
   1.203 -      std::cout << "preflow ..." << std::endl;
   1.204 -      for (Graph::EdgeIt e(g); e!=INVALID; ++e) flow.set(e, 0);
   1.205 -      ts.reset();
   1.206 -      max_flow_test.run();
   1.207 -      std::cout << "elapsed time: " << ts << std::endl;
   1.208 -      std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
   1.209 -    }
   1.210 -
   1.211 -    {
   1.212 -      std::cout << "physical blocking flow augmentation ..." << std::endl;
   1.213 -      for (Graph::EdgeIt e(g); e!=INVALID; ++e) flow.set(e, 0);
   1.214 -      ts.reset();
   1.215 -      int i=0;
   1.216 -      while (augmenting_flow_test.augmentOnBlockingFlow<MutableGraph>()) { ++i; }
   1.217 -      std::cout << "elapsed time: " << ts << std::endl;
   1.218 -      std::cout << "number of augmentation phases: " << i << std::endl; 
   1.219 -      std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
   1.220 -    }
   1.221 -
   1.222 -//     {
   1.223 -//       std::cout << "faster physical blocking flow augmentation ..." << std::endl;
   1.224 -//       FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
   1.225 -//       ts.reset();
   1.226 -//       int i=0;
   1.227 -//       while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) { ++i; }
   1.228 -//       std::cout << "elapsed time: " << ts << std::endl;
   1.229 -//       std::cout << "number of augmentation phases: " << i << std::endl; 
   1.230 -//       std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
   1.231 -//     }
   1.232 -
   1.233 -    {
   1.234 -      std::cout << "on-the-fly blocking flow augmentation ..." << std::endl;
   1.235 -      for (Graph::EdgeIt e(g); e!=INVALID; ++e) flow.set(e, 0);
   1.236 -      ts.reset();
   1.237 -      int i=0;
   1.238 -      while (augmenting_flow_test.augmentOnBlockingFlow2()) { ++i; }
   1.239 -      std::cout << "elapsed time: " << ts << std::endl;
   1.240 -      std::cout << "number of augmentation phases: " << i << std::endl; 
   1.241 -      std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
   1.242 -    }
   1.243 -
   1.244 -    {
   1.245 -      std::cout << "on-the-fly shortest path augmentation ..." << std::endl;
   1.246 -      for (Graph::EdgeIt e(g); e!=INVALID; ++e) flow.set(e, 0);
   1.247 -      ts.reset();
   1.248 -      int i=0;
   1.249 -      while (augmenting_flow_test.augmentOnShortestPath()) { ++i; }
   1.250 -      std::cout << "elapsed time: " << ts << std::endl;
   1.251 -      std::cout << "number of augmentation phases: " << i << std::endl; 
   1.252 -      std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
   1.253 -    }
   1.254 -  }
   1.255 -
   1.256 -  return 0;
   1.257 -}