Three new methods in UnionFindEnum.
UnionFindEnum completed.
     7 #include <LEDA/graph.h>
 
     8 #include <LEDA/mcb_matching.h>
 
    10 #include <LEDA/graph_gen.h>
 
    12 #include <leda_graph_wrapper.h>
 
    13 #include <list_graph.h>
 
    14 //#include <smart_graph.h>
 
    16 #include <time_measure.h>
 
    17 #include <for_each_macros.h>
 
    18 //#include <bfs_iterator.h>
 
    19 #include <graph_wrapper.h>
 
    21 #include <edmonds_karp.h>
 
    25  * Inicializalja a veletlenszamgeneratort.
 
    26  * Figyelem, ez nem jo igazi random szamokhoz,
 
    27  * erre ne bizzad a titkaidat!
 
    31 	unsigned int seed = getpid();
 
    39  * Egy veletlen int-et ad vissza 0 es m-1 kozott.
 
    43   return int( double(m) * rand() / (RAND_MAX + 1.0) );
 
    51   //lg.make_undirected();
 
    52   typedef LedaGraphWrapper<leda::graph> Graph;
 
    56   //typedef UndirListGraph Graph; 
 
    59   typedef Graph::Node Node;
 
    60   typedef Graph::NodeIt NodeIt;
 
    61   typedef Graph::Edge Edge;
 
    62   typedef Graph::EdgeIt EdgeIt;
 
    63   typedef Graph::OutEdgeIt OutEdgeIt;
 
    65   std::vector<Graph::Node> s_nodes;
 
    66   std::vector<Graph::Node> t_nodes;
 
    69   std::cout << "number of nodes in the first color class=";
 
    72   std::cout << "number of nodes in the second color class=";
 
    75   std::cout << "number of edges=";
 
    78   std::cout << "A bipartite graph is a random group graph if the color classes \nA and B are partitiones to A_0, A_1, ..., A_{k-1} and B_0, B_1, ..., B_{k-1} \nas equally as possible \nand the edges from A_i goes to A_{i-1 mod k} and A_{i+1 mod k}.\n";
 
    79   std::cout << "number of groups in LEDA random group graph=";
 
    82   leda_list<leda_node> lS;
 
    83   leda_list<leda_node> lT;
 
    84   random_bigraph(lg, a, b, m, lS, lT, k);
 
    86 //   for (int i=0; i<a; ++i) s_nodes.push_back(g.addNode());
 
    87 //   for (int i=0; i<b; ++i) t_nodes.push_back(g.addNode());
 
    90 //   for(int i=0; i<m; ++i) {
 
    91 //     g.addEdge(s_nodes[random(a)], t_nodes[random(b)]);
 
    94   Graph::NodeMap<int> ref_map(g, -1);
 
    96   IterableBoolMap< Graph::NodeMap<int> > bipartite_map(ref_map);
 
    97 //   for (int i=0; i<a; ++i) bipartite_map.insert(s_nodes[i], false);
 
    98 //   for (int i=0; i<b; ++i) bipartite_map.insert(t_nodes[i], true);
 
   100   forall(ln, lS) bipartite_map.insert(ln, false);
 
   101   forall(ln, lT) bipartite_map.insert(ln, true);
 
   103   typedef BipartiteGraphWrapper<Graph> BGW;
 
   104   BGW bgw(g, bipartite_map);
 
   106   //  BGW::NodeMap<int> dbyj(bgw);
 
   107   //  BGW::EdgeMap<int> dbyxcj(bgw);
 
   109   typedef stGraphWrapper<BGW> stGW;
 
   111   ConstMap<stGW::Edge, int> const1map(1);
 
   112   stGW::EdgeMap<int> flow(stgw);
 
   115   FOR_EACH_LOC(stGW::EdgeIt, e, stgw) flow.set(e, 0);
 
   117   //  stGW::EdgeMap<int> pre_flow(stgw);
 
   118   Preflow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> > 
 
   119     pre_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, flow/*, true*/);
 
   121   std::cout << "HUGO pre flow value: " << pre_flow_test.flowValue() << std::endl;
 
   122   std::cout << "elapsed time: " << ts << std::endl;
 
   123 //   FOR_EACH_LOC(stGW::EdgeIt, e, stgw) { 
 
   124 //     std::cout << e << ": " << pre_flow[e] << "\n"; 
 
   129   leda_list<leda_edge> ml=MAX_CARD_BIPARTITE_MATCHING(lg);
 
   130   //  stGW::EdgeMap<int> pre_flow(stgw);
 
   131   //Preflow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> > 
 
   132   //  pre_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, pre_flow, true);
 
   133   //pre_flow_test.run();
 
   134   std::cout << "LEDA matching value: " << ml.size() << std::endl;
 
   135   std::cout << "elapsed time: " << ts << std::endl;
 
   136 //   FOR_EACH_LOC(stGW::EdgeIt, e, stgw) { 
 
   137 //     std::cout << e << ": " << pre_flow[e] << "\n"; 
 
   141   FOR_EACH_LOC(stGW::EdgeIt, e, stgw) flow.set(e, 0);
 
   143   MaxFlow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> > 
 
   144     max_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, flow);
 
   145 //  while (max_flow_test.augmentOnShortestPath()) { }
 
   146   typedef ListGraph MutableGraph;
 
   147 //  while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) {
 
   148   while (max_flow_test.augmentOnBlockingFlow2()) {
 
   149    std::cout << max_flow_test.flowValue() << std::endl;
 
   151   std::cout << "HUGO blocking flow value: " << max_flow_test.flowValue() << std::endl;
 
   152   std::cout << "elapsed time: " << ts << std::endl;
 
   153 //   FOR_EACH_LOC(stGW::EdgeIt, e, stgw) { 
 
   154 //     std::cout << e << ": " << max_flow[e] << "\n"; 
 
   156 //   std::cout << "\n";