src/work/marci/edmonds_karp_demo.cc
changeset 466 cd40ecf4d2a9
parent 418 32a2a16027e0
child 472 052af4060f3e
equal deleted inserted replaced
29:834b12e83cf8 30:76ec1617af14
    69   Graph::EdgeMap<int> cap(G);
    69   Graph::EdgeMap<int> cap(G);
    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   Preflow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
    75   Preflow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
    76     pre_flow_ize(G, s, t, cap, flow, false);
    76     pre_flow_ize(G, s, t, cap, flow/*, false*/);
    77   PreflowRes<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
    77 //   PreflowRes<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
    78     pre_flow_res(G, s, t, cap, flow, true);
    78 //     pre_flow_res(G, s, t, cap, flow/*, true*/);
    79   MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
    79   MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
    80     max_flow_test(G, s, t, cap, flow);
    80     max_flow_test(G, s, t, cap, flow);
    81 
    81 
    82   {
    82   {
    83     std::cout << "preflow ..." << std::endl;
    83     std::cout << "preflow ..." << std::endl;
    89 
    89 
    90   {
    90   {
    91     std::cout << "preflow ..." << std::endl;
    91     std::cout << "preflow ..." << std::endl;
    92     FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
    92     FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
    93     ts.reset();
    93     ts.reset();
    94     pre_flow_ize.run();
    94     pre_flow_ize.preflow(Preflow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >::GEN_FLOW);
    95     std::cout << "elapsed time: " << ts << std::endl;
    95     std::cout << "elapsed time: " << ts << std::endl;
    96     std::cout << "flow value: "<< pre_flow_ize.flowValue() << std::endl;
    96     std::cout << "flow value: "<< pre_flow_ize.flowValue() << std::endl;
    97   }
    97   }
    98 
    98 
    99   {
    99 //   {
   100     std::cout << "wrapped preflow ..." << std::endl;
   100 //     std::cout << "wrapped preflow ..." << std::endl;
   101     FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
   101 //     FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
   102     ts.reset();
   102 //     ts.reset();
   103     pre_flow_res.run();
   103 //     pre_flow_res.run();
   104     std::cout << "elapsed time: " << ts << std::endl;
   104 //     std::cout << "elapsed time: " << ts << std::endl;
   105     std::cout << "flow value: "<< pre_flow_test.flowValue() << std::endl;
   105 //     std::cout << "flow value: "<< pre_flow_test.flowValue() << std::endl;
   106   }
   106 //   }
   107 
   107 
   108   {
   108   {
   109     std::cout << "physical blocking flow augmentation ..." << std::endl;
   109     std::cout << "physical blocking flow augmentation ..." << std::endl;
   110     FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
   110     FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
   111     ts.reset();
   111     ts.reset();