# HG changeset patch # User marci # Date 1083254896 0 # Node ID 5fa75db9ebb4f192c6e5f3f1c9e888887b8efac0 # Parent 229a16b5fd0f576afb2840162e0d2755275472f7 edmonds_karp_demo->max_flow_demo diff -r 229a16b5fd0f -r 5fa75db9ebb4 src/work/marci/edmonds_karp_demo.cc --- a/src/work/marci/edmonds_karp_demo.cc Thu Apr 29 16:07:10 2004 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,154 +0,0 @@ -// -*- c++ -*- -#include -#include - -#include -#include -#include -//#include -#include -//#include -#include -//#include -#include - -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); - Timer ts; - Graph::EdgeMap flow(G); //0 flow - Preflow, Graph::EdgeMap > - pre_flow_test(G, s, t, cap, flow/*, true*/); - // Preflow, Graph::EdgeMap > - // pre_flow_ize(G, s, t, cap, flow/*, false*/); -// PreflowRes, Graph::EdgeMap > -// pre_flow_res(G, s, t, cap, flow/*, true*/); - //MaxFlow, Graph::EdgeMap > - // max_flow_test(G, s, t, cap, flow); - - { - std::cout << "preflow ..." << std::endl; - ts.reset(); - pre_flow_test.run(); - std::cout << "elapsed time: " << ts << std::endl; - std::cout << "flow value: "<< pre_flow_test.flowValue() << std::endl; - } - - { - std::cout << "preflow ..." << std::endl; - FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0); - ts.reset(); - pre_flow_test.preflow(Preflow, Graph::EdgeMap >::GEN_FLOW); - std::cout << "elapsed time: " << ts << std::endl; - std::cout << "flow value: "<< pre_flow_test.flowValue() << std::endl; - } - -// { -// std::cout << "wrapped preflow ..." << std::endl; -// FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0); -// ts.reset(); -// pre_flow_res.run(); -// std::cout << "elapsed time: " << ts << std::endl; -// std::cout << "flow value: "<< pre_flow_test.flowValue() << std::endl; -// } - - { - std::cout << "physical blocking flow augmentation ..." << std::endl; - FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0); - ts.reset(); - int i=0; - while (pre_flow_test.augmentOnBlockingFlow()) { ++i; } - std::cout << "elapsed time: " << ts << std::endl; - std::cout << "number of augmentation phases: " << i << std::endl; - std::cout << "flow value: "<< pre_flow_test.flowValue() << std::endl; - } - -// { -// std::cout << "faster physical blocking flow augmentation ..." << std::endl; -// FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0); -// ts.reset(); -// int i=0; -// while (max_flow_test.augmentOnBlockingFlow1()) { ++i; } -// std::cout << "elapsed time: " << ts << std::endl; -// std::cout << "number of augmentation phases: " << i << std::endl; -// std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl; -// } - - { - std::cout << "on-the-fly blocking flow augmentation ..." << std::endl; - FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0); - ts.reset(); - int i=0; - while (pre_flow_test.augmentOnBlockingFlow2()) { ++i; } - std::cout << "elapsed time: " << ts << std::endl; - std::cout << "number of augmentation phases: " << i << std::endl; - std::cout << "flow value: "<< pre_flow_test.flowValue() << std::endl; - } - - { - std::cout << "on-the-fly shortest path augmentation ..." << std::endl; - FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0); - ts.reset(); - int i=0; - while (pre_flow_test.augmentOnShortestPath()) { ++i; } - std::cout << "elapsed time: " << ts << std::endl; - std::cout << "number of augmentation phases: " << i << std::endl; - std::cout << "flow value: "<< pre_flow_test.flowValue() << std::endl; - } - - - return 0; -} diff -r 229a16b5fd0f -r 5fa75db9ebb4 src/work/marci/max_flow_demo.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/work/marci/max_flow_demo.cc Thu Apr 29 16:08:16 2004 +0000 @@ -0,0 +1,154 @@ +// -*- c++ -*- +#include +#include + +#include +#include +#include +//#include +#include +//#include +#include +//#include +#include + +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); + Timer ts; + Graph::EdgeMap flow(G); //0 flow + Preflow, Graph::EdgeMap > + pre_flow_test(G, s, t, cap, flow/*, true*/); + // Preflow, Graph::EdgeMap > + // pre_flow_ize(G, s, t, cap, flow/*, false*/); +// PreflowRes, Graph::EdgeMap > +// pre_flow_res(G, s, t, cap, flow/*, true*/); + //MaxFlow, Graph::EdgeMap > + // max_flow_test(G, s, t, cap, flow); + + { + std::cout << "preflow ..." << std::endl; + ts.reset(); + pre_flow_test.run(); + std::cout << "elapsed time: " << ts << std::endl; + std::cout << "flow value: "<< pre_flow_test.flowValue() << std::endl; + } + + { + std::cout << "preflow ..." << std::endl; + FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0); + ts.reset(); + pre_flow_test.preflow(Preflow, Graph::EdgeMap >::GEN_FLOW); + std::cout << "elapsed time: " << ts << std::endl; + std::cout << "flow value: "<< pre_flow_test.flowValue() << std::endl; + } + +// { +// std::cout << "wrapped preflow ..." << std::endl; +// FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0); +// ts.reset(); +// pre_flow_res.run(); +// std::cout << "elapsed time: " << ts << std::endl; +// std::cout << "flow value: "<< pre_flow_test.flowValue() << std::endl; +// } + + { + std::cout << "physical blocking flow augmentation ..." << std::endl; + FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0); + ts.reset(); + int i=0; + while (pre_flow_test.augmentOnBlockingFlow()) { ++i; } + std::cout << "elapsed time: " << ts << std::endl; + std::cout << "number of augmentation phases: " << i << std::endl; + std::cout << "flow value: "<< pre_flow_test.flowValue() << std::endl; + } + +// { +// std::cout << "faster physical blocking flow augmentation ..." << std::endl; +// FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0); +// ts.reset(); +// int i=0; +// while (max_flow_test.augmentOnBlockingFlow1()) { ++i; } +// std::cout << "elapsed time: " << ts << std::endl; +// std::cout << "number of augmentation phases: " << i << std::endl; +// std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl; +// } + + { + std::cout << "on-the-fly blocking flow augmentation ..." << std::endl; + FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0); + ts.reset(); + int i=0; + while (pre_flow_test.augmentOnBlockingFlow2()) { ++i; } + std::cout << "elapsed time: " << ts << std::endl; + std::cout << "number of augmentation phases: " << i << std::endl; + std::cout << "flow value: "<< pre_flow_test.flowValue() << std::endl; + } + + { + std::cout << "on-the-fly shortest path augmentation ..." << std::endl; + FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0); + ts.reset(); + int i=0; + while (pre_flow_test.augmentOnShortestPath()) { ++i; } + std::cout << "elapsed time: " << ts << std::endl; + std::cout << "number of augmentation phases: " << i << std::endl; + std::cout << "flow value: "<< pre_flow_test.flowValue() << std::endl; + } + + + return 0; +}