src/work/marci/preflow_demo_jacint.cc
changeset 1262 61f989e3e525
parent 921 818510fa3d99
equal deleted inserted replaced
5:40eed3e56363 6:36d64d7a5d49
    29   max_flow_test.run();
    29   max_flow_test.run();
    30   ListGraph::NodeMap<bool> cut(G); 
    30   ListGraph::NodeMap<bool> cut(G); 
    31   max_flow_test.mincut(cut);
    31   max_flow_test.mincut(cut);
    32   int cut_value=0;
    32   int cut_value=0;
    33   for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
    33   for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
    34     if (cut.get(G.tail(e)) && !cut.get(G.head(e))) cut_value+=cap.get(e);
    34     if (cut.get(G.source(e)) && !cut.get(G.target(e))) cut_value+=cap.get(e);
    35   }
    35   }
    36   double post_time=currTime();
    36   double post_time=currTime();
    37   //std::cout << "maximum flow: "<< std::endl;
    37   //std::cout << "maximum flow: "<< std::endl;
    38   //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) { 
    38   //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) { 
    39   //  std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
    39   //  std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
    40   //}
    40   //}
    41   //std::cout<<std::endl;
    41   //std::cout<<std::endl;
    42   std::cout << "elapsed time: " << post_time-pre_time << " sec"<< std::endl; 
    42   std::cout << "elapsed time: " << post_time-pre_time << " sec"<< std::endl; 
    43   std::cout << "flow value: "<< max_flow_test.maxflow() << std::endl;
    43   std::cout << "flow value: "<< max_flow_test.maxflow() << std::endl;
    44   std::cout << "cut value: "<< cut_value << std::endl;
    44   std::cout << "cut value: "<< cut_value << std::endl;
    53   max_flow_test.run();
    53   max_flow_test.run();
    54   ListGraph::NodeMap<bool> cut(G);
    54   ListGraph::NodeMap<bool> cut(G);
    55   max_flow_test.mincut(cut);
    55   max_flow_test.mincut(cut);
    56   int cut_value=0;
    56   int cut_value=0;
    57   for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
    57   for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
    58     if (cut.get(G.tail(e)) && !cut.get(G.head(e))) cut_value+=cap.get(e);
    58     if (cut.get(G.source(e)) && !cut.get(G.target(e))) cut_value+=cap.get(e);
    59   }
    59   }
    60   double post_time=currTime();
    60   double post_time=currTime();
    61   //std::cout << "maximum flow: "<< std::endl;
    61   //std::cout << "maximum flow: "<< std::endl;
    62   //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) { 
    62   //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) { 
    63   //  std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
    63   //  std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
    64   //}
    64   //}
    65   //std::cout<<std::endl;
    65   //std::cout<<std::endl;
    66   std::cout << "elapsed time: " << post_time-pre_time << " sec"<< std::endl; 
    66   std::cout << "elapsed time: " << post_time-pre_time << " sec"<< std::endl; 
    67   std::cout << "flow value: "<< max_flow_test.maxflow() << std::endl;
    67   std::cout << "flow value: "<< max_flow_test.maxflow() << std::endl;
    68   std::cout << "cut value: "<< cut_value << std::endl;
    68   std::cout << "cut value: "<< cut_value << std::endl;