src/work/marci/leda/bipartite_matching_comparison.cc
changeset 921 818510fa3d99
parent 771 ad7dff9ee2fd
child 986 e997802b855c
equal deleted inserted replaced
0:cc2e5f1b11ce 1:16a09f55620e
    11 
    11 
    12 #include <leda_graph_wrapper.h>
    12 #include <leda_graph_wrapper.h>
    13 #include <sage_graph.h>
    13 #include <sage_graph.h>
    14 //#include <smart_graph.h>
    14 //#include <smart_graph.h>
    15 //#include <dimacs.h>
    15 //#include <dimacs.h>
    16 #include <hugo/time_measure.h>
    16 #include <lemon/time_measure.h>
    17 #include <for_each_macros.h>
    17 #include <for_each_macros.h>
    18 #include <hugo/graph_wrapper.h>
    18 #include <lemon/graph_wrapper.h>
    19 #include <bipartite_graph_wrapper.h>
    19 #include <bipartite_graph_wrapper.h>
    20 #include <hugo/maps.h>
    20 #include <lemon/maps.h>
    21 #include <hugo/max_flow.h>
    21 #include <lemon/max_flow.h>
    22 
    22 
    23 using std::cin;
    23 using std::cin;
    24 using std::cout;
    24 using std::cout;
    25 using std::endl;
    25 using std::endl;
    26 
    26 
    27 using namespace hugo;
    27 using namespace lemon;
    28 
    28 
    29 int main() {
    29 int main() {
    30   //for leda graph
    30   //for leda graph
    31   leda::graph lg;
    31   leda::graph lg;
    32   //lg.make_undirected();
    32   //lg.make_undirected();
    89   ts.reset();
    89   ts.reset();
    90   FOR_EACH_LOC(stGW::EdgeIt, e, stgw) flow.set(e, 0);
    90   FOR_EACH_LOC(stGW::EdgeIt, e, stgw) flow.set(e, 0);
    91   MaxFlow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> > 
    91   MaxFlow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> > 
    92     max_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, flow/*, true*/);
    92     max_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, flow/*, true*/);
    93   max_flow_test.run();
    93   max_flow_test.run();
    94   cout << "HUGO max matching algorithm based on preflow." << endl 
    94   cout << "LEMON max matching algorithm based on preflow." << endl 
    95 	    << "Size of matching: " 
    95 	    << "Size of matching: " 
    96 	    << max_flow_test.flowValue() << endl;
    96 	    << max_flow_test.flowValue() << endl;
    97   cout << "elapsed time: " << ts << endl << endl;
    97   cout << "elapsed time: " << ts << endl << endl;
    98 
    98 
    99   ts.reset();  
    99   ts.reset();  
   105 
   105 
   106 //   ts.reset();
   106 //   ts.reset();
   107 //   FOR_EACH_LOC(stGW::EdgeIt, e, stgw) flow.set(e, 0);
   107 //   FOR_EACH_LOC(stGW::EdgeIt, e, stgw) flow.set(e, 0);
   108 //   typedef SageGraph MutableGraph;
   108 //   typedef SageGraph MutableGraph;
   109 //   while (max_flow_test.augmentOnBlockingFlow<MutableGraph>()) { }
   109 //   while (max_flow_test.augmentOnBlockingFlow<MutableGraph>()) { }
   110 //   cout << "HUGO max matching algorithm based on blocking flow augmentation." 
   110 //   cout << "LEMON max matching algorithm based on blocking flow augmentation." 
   111 // 	    << endl << "Matching size: " 
   111 // 	    << endl << "Matching size: " 
   112 // 	    << max_flow_test.flowValue() << endl;
   112 // 	    << max_flow_test.flowValue() << endl;
   113 //   cout << "elapsed time: " << ts << endl << endl;
   113 //   cout << "elapsed time: " << ts << endl << endl;
   114 
   114 
   115   {
   115   {
   139   ts.reset();
   139   ts.reset();
   140   MaxFlow<SageGraph, int, ConstMap<SageGraph::Edge, int>, 
   140   MaxFlow<SageGraph, int, ConstMap<SageGraph::Edge, int>, 
   141     SageGraph::EdgeMap<int> > 
   141     SageGraph::EdgeMap<int> > 
   142     max_flow_test(hg, s, t, cm, flow);
   142     max_flow_test(hg, s, t, cm, flow);
   143   max_flow_test.run();
   143   max_flow_test.run();
   144   cout << "HUGO max matching algorithm on SageGraph by copying the graph, based on preflow." 
   144   cout << "LEMON max matching algorithm on SageGraph by copying the graph, based on preflow." 
   145 	    << endl 
   145 	    << endl 
   146 	    << "Size of matching: " 
   146 	    << "Size of matching: " 
   147 	    << max_flow_test.flowValue() << endl;
   147 	    << max_flow_test.flowValue() << endl;
   148   cout << "elapsed time: " << ts << endl << endl;
   148   cout << "elapsed time: " << ts << endl << endl;
   149   }
   149   }