marci@174: // -*- c++ -*- marci@73: #include marci@73: #include marci@73: marci@174: #include marci@174: #include marci@174: #include marci@174: #include marci@73: #include marci@155: #include marci@73: marci@266: class CM { marci@266: public: marci@266: template int get(T) const {return 1;} marci@266: }; marci@266: alpar@105: using namespace hugo; marci@73: marci@73: // Use a DIMACS max flow file as stdin. marci@73: // read_dimacs_demo < dimacs_max_flow_file marci@139: marci@174: marci@174: // struct Ize { marci@174: // }; marci@139: marci@174: // struct Mize { marci@174: // Ize bumm; marci@174: // }; marci@139: marci@174: // template marci@174: // class Huha { marci@174: // public: marci@174: // int u; marci@174: // B brr; marci@174: // }; marci@174: marci@139: marci@73: int main(int, char **) { marci@73: marci@174: typedef ListGraph MutableGraph; marci@139: marci@243: //typedef SmartGraph Graph; marci@243: typedef ListGraph Graph; marci@174: typedef Graph::Node Node; marci@174: typedef Graph::EdgeIt EdgeIt; marci@139: marci@139: marci@174: // Mize mize[10]; marci@174: // Mize bize[0]; marci@174: // Mize zize; marci@174: // typedef Mize Tize[0]; marci@146: marci@174: // std::cout << &zize << " " << sizeof(mize) << sizeof(Tize) << std::endl; marci@174: // std::cout << sizeof(bize) << std::endl; marci@146: marci@146: marci@174: // Huha k; marci@174: // std::cout << sizeof(k) << std::endl; marci@139: marci@174: marci@174: // struct Bumm { marci@174: // //int a; marci@174: // bool b; marci@174: // }; marci@174: marci@174: // std::cout << sizeof(Bumm) << std::endl; marci@174: marci@174: marci@174: Graph G; marci@174: Node s, t; marci@174: Graph::EdgeMap cap(G); marci@73: readDimacsMaxFlow(std::cin, G, s, t, cap); marci@155: marci@174: // typedef TrivGraphWrapper TGW; marci@174: // TGW gw(G); marci@174: // TGW::NodeIt sw; marci@174: // gw./*getF*/first(sw); marci@174: // std::cout << "p1:" << gw.nodeNum() << std::endl; marci@174: // gw.erase(sw); marci@174: // std::cout << "p2:" << gw.nodeNum() << std::endl; marci@174: marci@174: // typedef const Graph cLG; marci@174: // typedef TrivGraphWrapper CTGW; marci@174: // CTGW cgw(G); marci@174: // CTGW::NodeIt csw; marci@174: // cgw./*getF*/first(csw); marci@174: // std::cout << "p1:" << cgw.nodeNum() << std::endl; marci@174: // //cgw.erase(csw); marci@174: // std::cout << "p2:" << cgw.nodeNum() << std::endl; marci@174: marci@73: marci@133: { marci@266: typedef TrivGraphWrapper GW; marci@266: GW gw(G); marci@174: std::cout << "edmonds karp demo (physical blocking flow augmentation)..." << std::endl; marci@271: GW::EdgeMap flow(gw); //0 flow marci@73: marci@174: Timer ts; marci@174: ts.reset(); marci@174: marci@266: typedef GW::EdgeMapWrapper< Graph::EdgeMap, int > EMW; marci@266: EMW cw(cap); marci@267: MaxFlow, EMW > max_flow_test(gw, s, t, flow, cw); marci@174: int i=0; marci@174: while (max_flow_test.augmentOnBlockingFlow()) { marci@174: // for(EdgeIt e=G.template first(); e.valid(); ++e) { marci@168: // std::cout<<"("<"<(); e.valid(); ++e) { marci@174: // std::cout<<"("<"< GW; marci@268: GW gw(G); marci@268: std::cout << "edmonds karp demo (physical blocking flow 1 augmentation)..." << std::endl; marci@271: GW::EdgeMap flow(gw); //0 flow marci@266: marci@268: Timer ts; marci@268: ts.reset(); marci@266: marci@268: typedef GW::EdgeMapWrapper< Graph::EdgeMap, int > EMW; marci@268: EMW cw(cap); marci@268: MaxFlow, EMW > max_flow_test(gw, s, t, flow, cw); marci@268: int i=0; marci@268: while (max_flow_test.augmentOnBlockingFlow1()) { marci@268: // for(EdgeIt e=G.template first(); e.valid(); ++e) { marci@268: // std::cout<<"("<"<(); e.valid(); ++e) { marci@268: // std::cout<<"("<"< GW; marci@269: GW gw(G); marci@269: std::cout << "edmonds karp demo (on-the-fly blocking flow augmentation)..." << std::endl; marci@271: GW::EdgeMap flow(gw); //0 flow marci@266: marci@269: Timer ts; marci@269: ts.reset(); marci@266: marci@269: typedef GW::EdgeMapWrapper< Graph::EdgeMap, int > EMW; marci@269: EMW cw(cap); marci@269: MaxFlow, EMW > max_flow_test(gw, s, t, flow, cw); marci@269: int i=0; marci@269: while (max_flow_test.augmentOnBlockingFlow2()) { marci@269: // for(EdgeIt e=G.template first(); e.valid(); ++e) { marci@269: // std::cout<<"("<"<(); e.valid(); ++e) { marci@269: // std::cout<<"("<"< GW; marci@266: GW gw(G); marci@266: std::cout << "edmonds karp demo (on-the-fly shortest path augmentation)..." << std::endl; marci@266: GW::EdgeMap flow(gw); //0 flow marci@206: marci@206: Timer ts; marci@206: ts.reset(); marci@206: marci@266: typedef GW::EdgeMapWrapper< Graph::EdgeMap, int > EMW; marci@266: EMW cw(cap); marci@266: MaxFlow, EMW> max_flow_test(gw, s, t, flow, cw); marci@174: int i=0; marci@174: while (max_flow_test.augmentOnShortestPath()) { marci@174: // for(EdgeIt e=G.template first(); e.valid(); ++e) { marci@168: // std::cout<<"("<"<(); e.valid(); ++e) { marci@174: // std::cout<<"("<"<