diff -r 19f3943521ab -r 3fefabfd00b7 src/work/marci/experiment/edmonds_karp_demo.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/work/marci/experiment/edmonds_karp_demo.cc Sat Apr 03 17:26:46 2004 +0000 @@ -0,0 +1,218 @@ +// -*- c++ -*- +#include +#include + +#include +#include +#include +#include +#include +#include + +class CM { +public: + template int get(T) const {return 1;} +}; + +using namespace hugo; + +// Use a DIMACS max flow file as stdin. +// read_dimacs_demo < dimacs_max_flow_file + + +// struct Ize { +// }; + +// struct Mize { +// Ize bumm; +// }; + +// template +// class Huha { +// public: +// int u; +// B brr; +// }; + + +int main(int, char **) { + + typedef ListGraph MutableGraph; + + //typedef SmartGraph Graph; + typedef ListGraph Graph; + typedef Graph::Node Node; + typedef Graph::EdgeIt EdgeIt; + + +// Mize mize[10]; +// Mize bize[0]; +// Mize zize; +// typedef Mize Tize[0]; + +// std::cout << &zize << " " << sizeof(mize) << sizeof(Tize) << std::endl; +// std::cout << sizeof(bize) << std::endl; + + +// Huha k; +// std::cout << sizeof(k) << std::endl; + + +// struct Bumm { +// //int a; +// bool b; +// }; + +// std::cout << sizeof(Bumm) << std::endl; + + + Graph G; + Node s, t; + Graph::EdgeMap cap(G); + readDimacsMaxFlow(std::cin, G, s, t, cap); + +// typedef TrivGraphWrapper TGW; +// TGW gw(G); +// TGW::NodeIt sw; +// gw./*getF*/first(sw); +// std::cout << "p1:" << gw.nodeNum() << std::endl; +// gw.erase(sw); +// std::cout << "p2:" << gw.nodeNum() << std::endl; + +// typedef const Graph cLG; +// typedef TrivGraphWrapper CTGW; +// CTGW cgw(G); +// CTGW::NodeIt csw; +// cgw./*getF*/first(csw); +// std::cout << "p1:" << cgw.nodeNum() << std::endl; +// //cgw.erase(csw); +// std::cout << "p2:" << cgw.nodeNum() << std::endl; + + + { + typedef TrivGraphWrapper GW; + GW gw(G); + std::cout << "edmonds karp demo (physical blocking flow augmentation)..." << std::endl; + GW::EdgeMap flow(gw); //0 flow + + Timer ts; + ts.reset(); + + typedef GW::EdgeMapWrapper< Graph::EdgeMap, int > EMW; + EMW cw(cap); + MaxFlow, EMW > max_flow_test(gw, s, t, flow, cw); + int i=0; + while (max_flow_test.augmentOnBlockingFlow()) { +// for(EdgeIt e=G.template first(); e.valid(); ++e) { +// std::cout<<"("<"<(); e.valid(); ++e) { +// std::cout<<"("<"< GW; + GW gw(G); + std::cout << "edmonds karp demo (physical blocking flow 1 augmentation)..." << std::endl; + GW::EdgeMap flow(gw); //0 flow + + Timer ts; + ts.reset(); + + typedef GW::EdgeMapWrapper< Graph::EdgeMap, int > EMW; + EMW cw(cap); + MaxFlow, EMW > max_flow_test(gw, s, t, flow, cw); + int i=0; + while (max_flow_test.augmentOnBlockingFlow1()) { +// for(EdgeIt e=G.template first(); e.valid(); ++e) { +// std::cout<<"("<"<(); e.valid(); ++e) { +// std::cout<<"("<"< GW; + GW gw(G); + std::cout << "edmonds karp demo (on-the-fly blocking flow augmentation)..." << std::endl; + GW::EdgeMap flow(gw); //0 flow + + Timer ts; + ts.reset(); + + typedef GW::EdgeMapWrapper< Graph::EdgeMap, int > EMW; + EMW cw(cap); + MaxFlow, EMW > max_flow_test(gw, s, t, flow, cw); + int i=0; + while (max_flow_test.augmentOnBlockingFlow2()) { +// for(EdgeIt e=G.template first(); e.valid(); ++e) { +// std::cout<<"("<"<(); e.valid(); ++e) { +// std::cout<<"("<"< GW; + GW gw(G); + std::cout << "edmonds karp demo (on-the-fly shortest path augmentation)..." << std::endl; + GW::EdgeMap flow(gw); //0 flow + + Timer ts; + ts.reset(); + + typedef GW::EdgeMapWrapper< Graph::EdgeMap, int > EMW; + EMW cw(cap); + MaxFlow, EMW> max_flow_test(gw, s, t, flow, cw); + int i=0; + while (max_flow_test.augmentOnShortestPath()) { +// for(EdgeIt e=G.template first(); e.valid(); ++e) { +// std::cout<<"("<"<(); e.valid(); ++e) { +// std::cout<<"("<"<