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