src/work/marci/edmonds_karp_demo.cc
changeset 413 9cb93f692e92
parent 389 770cc1f4861f
child 415 679e64913c5e
equal deleted inserted replaced
26:387b1c26ebf4 27:e7acfb0baef5
     7 #include <dimacs.h>
     7 #include <dimacs.h>
     8 #include <edmonds_karp.h>
     8 #include <edmonds_karp.h>
     9 #include <time_measure.h>
     9 #include <time_measure.h>
    10 //#include <graph_wrapper.h>
    10 //#include <graph_wrapper.h>
    11 #include <preflow.h>
    11 #include <preflow.h>
    12 #include <preflowproba.h>
    12 #include <preflow_res.h>
    13 #include <for_each_macros.h>
    13 #include <for_each_macros.h>
    14 
    14 
    15 using namespace hugo;
    15 using namespace hugo;
    16 
    16 
    17 // Use a DIMACS max flow file as stdin.
    17 // Use a DIMACS max flow file as stdin.
    70   readDimacsMaxFlow(std::cin, G, s, t, cap);
    70   readDimacsMaxFlow(std::cin, G, s, t, cap);
    71   Timer ts;
    71   Timer ts;
    72   Graph::EdgeMap<int> flow(G); //0 flow
    72   Graph::EdgeMap<int> flow(G); //0 flow
    73   Preflow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
    73   Preflow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
    74     pre_flow_test(G, s, t, cap, flow, true);
    74     pre_flow_test(G, s, t, cap, flow, true);
    75   PreflowProba<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
    75   PreflowRes<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
    76     pre_flow_proba(G, s, t, cap, flow, true, true);
    76     pre_flow_res(G, s, t, cap, flow, true);
    77   MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
    77   MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
    78     max_flow_test(G, s, t, cap, flow);
    78     max_flow_test(G, s, t, cap, flow);
    79 
    79 
    80   {
    80   {
    81     std::cout << "preflow ..." << std::endl;
    81     std::cout << "preflow ..." << std::endl;
    87 
    87 
    88   {
    88   {
    89     std::cout << "wrapped preflow ..." << std::endl;
    89     std::cout << "wrapped preflow ..." << std::endl;
    90     FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
    90     FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
    91     ts.reset();
    91     ts.reset();
    92     pre_flow_proba.run();
    92     pre_flow_res.run();
    93     std::cout << "elapsed time: " << ts << std::endl;
    93     std::cout << "elapsed time: " << ts << std::endl;
    94     std::cout << "flow value: "<< pre_flow_test.flowValue() << std::endl;
    94     std::cout << "flow value: "<< pre_flow_test.flowValue() << std::endl;
    95   }
    95   }
    96 
    96 
    97   {
    97   {