Three new methods in UnionFindEnum.
UnionFindEnum completed.
     7 #include <list_graph.h>
 
     8 //#include <smart_graph.h>
 
    10 #include <time_measure.h>
 
    11 #include <for_each_macros.h>
 
    12 #include <bfs_iterator.h>
 
    13 #include <graph_wrapper.h>
 
    18  * Inicializalja a veletlenszamgeneratort.
 
    19  * Figyelem, ez nem jo igazi random szamokhoz,
 
    20  * erre ne bizzad a titkaidat!
 
    24 	unsigned int seed = getpid();
 
    32  * Egy veletlen int-et ad vissza 0 es m-1 kozott.
 
    36   return int( double(m) * rand() / (RAND_MAX + 1.0) );
 
    42   typedef UndirListGraph Graph; 
 
    43   typedef Graph::Node Node;
 
    44   typedef Graph::NodeIt NodeIt;
 
    45   typedef Graph::Edge Edge;
 
    46   typedef Graph::EdgeIt EdgeIt;
 
    47   typedef Graph::OutEdgeIt OutEdgeIt;
 
    51   std::vector<Graph::Node> s_nodes;
 
    52   std::vector<Graph::Node> t_nodes;
 
    55   std::cout << "number of nodes in the first color class=";
 
    58   std::cout << "number of nodes in the second color class=";
 
    61   std::cout << "number of edges=";
 
    65   for (int i=0; i<a; ++i) s_nodes.push_back(g.addNode());
 
    66   for (int i=0; i<b; ++i) t_nodes.push_back(g.addNode());
 
    69   for(int i=0; i<m; ++i) {
 
    70     g.addEdge(s_nodes[random(a)], t_nodes[random(b)]);
 
    73   Graph::NodeMap<int> ref_map(g, -1);
 
    75   IterableBoolMap< Graph::NodeMap<int> > bipartite_map(ref_map);
 
    76   for (int i=0; i<a; ++i) bipartite_map.insert(s_nodes[i], false);
 
    77   for (int i=0; i<b; ++i) bipartite_map.insert(t_nodes[i], true);
 
    80 //   std::cout << "These nodes will be in S:\n";
 
    81 //   //FIXME azert kellene ++, es invalid vizsgalat u-bol, hogy ezt le lehessen 
 
    82 //   //irni 1etlen FOR_EACH-csel.
 
    83 //   for (bipartite_map.first(u, false); g.valid(u); bipartite_map.next(u)) 
 
    84 //     std::cout << u << " ";
 
    86 //   std::cout << "These nodes will be in T:\n";
 
    87 //   for (bipartite_map.first(u, true); g.valid(u); bipartite_map.next(u)) 
 
    88 //     std::cout << u << " ";
 
    91   typedef BipartiteGraphWrapper<Graph> BGW;
 
    92   BGW bgw(g, bipartite_map);
 
    94 //   std::cout << "Nodes by NodeIt:\n";
 
    95 //   FOR_EACH_LOC(BGW::NodeIt, n, bgw) {
 
    96 //     std::cout << n << " ";
 
    99 //   std::cout << "Nodes in S by ClassNodeIt:\n";
 
   100 //   FOR_EACH_INC_LOC(BGW::ClassNodeIt, n, bgw, bgw.S_CLASS) {
 
   101 //     std::cout << n << " ";
 
   103 //   std::cout << "\n";
 
   104 //   std::cout << "Nodes in T by ClassNodeIt:\n";
 
   105 //   FOR_EACH_INC_LOC(BGW::ClassNodeIt, n, bgw, bgw.T_CLASS) {
 
   106 //     std::cout << n << " ";
 
   108 //   std::cout << "\n";
 
   109 //   std::cout << "Edges of the bipartite graph:\n";
 
   110 //   FOR_EACH_LOC(BGW::EdgeIt, e, bgw) {
 
   111 //     std::cout << bgw.tail(e) << "->" << bgw.head(e) << std::endl;
 
   114   BGW::NodeMap<int> dbyj(bgw);
 
   115   BGW::EdgeMap<int> dbyxcj(bgw);
 
   117   typedef stGraphWrapper<BGW> stGW;
 
   119   ConstMap<stGW::Edge, int> const1map(1);
 
   120 //  stGW::NodeMap<int> ize(stgw);
 
   122 //   BfsIterator< BGW, BGW::NodeMap<bool> > bfs(bgw);
 
   126 //   bfs.pushAndSetReached(BGW::Node(s));
 
   127 //   while (!bfs.finished()) { ++bfs; }
 
   129 //   FOR_EACH_LOC(stGW::NodeIt, n, stgw) { 
 
   130 //     std::cout << "out-edges of " << n << ":\n"; 
 
   131 //     FOR_EACH_INC_LOC(stGW::OutEdgeIt, e, stgw, n) { 
 
   132 //       std::cout << " " << e << "\n";
 
   133 //       std::cout << " aNode: " << stgw.aNode(e) << "\n";
 
   134 //       std::cout << " bNode: " << stgw.bNode(e) << "\n";      
 
   136 //     std::cout << "in-edges of " << n << ":\n"; 
 
   137 //     FOR_EACH_INC_LOC(stGW::InEdgeIt, e, stgw, n) { 
 
   138 //       std::cout << " " << e << "\n";
 
   139 //       std::cout << " aNode: " << stgw.aNode(e) << "\n";
 
   140 //       std::cout << " bNode: " << stgw.bNode(e) << "\n";     
 
   143 //   std::cout << "Edges of the stGraphWrapper:\n"; 
 
   144 //   FOR_EACH_LOC(stGW::EdgeIt, n, stgw) { 
 
   145 //     std::cout << " " << n << "\n";
 
   148 //   stGW::NodeMap<bool> b(stgw);
 
   149 //   FOR_EACH_LOC(stGW::NodeIt, n, stgw) { 
 
   150 //     std::cout << n << ": " << b[n] <<"\n";
 
   153 //   std::cout << "Bfs from s: \n";
 
   154 //   BfsIterator< stGW, stGW::NodeMap<bool> > bfs_stgw(stgw);
 
   155 //   bfs_stgw.pushAndSetReached(stgw.S_NODE);
 
   156 //   while (!bfs_stgw.finished()) { 
 
   157 //     std::cout << " " << stGW::OutEdgeIt(bfs_stgw) << "\n";
 
   164   stGW::EdgeMap<int> max_flow(stgw);
 
   165   MaxFlow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> > 
 
   166     max_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, max_flow);
 
   167 //  while (max_flow_test.augmentOnShortestPath()) { }
 
   168   typedef ListGraph MutableGraph;
 
   169 //  while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) {
 
   170   while (max_flow_test.augmentOnBlockingFlow2()) {
 
   171    std::cout << max_flow_test.flowValue() << std::endl;
 
   173   std::cout << "max flow value: " << max_flow_test.flowValue() << std::endl;
 
   174   std::cout << "elapsed time: " << ts << std::endl;
 
   175 //   FOR_EACH_LOC(stGW::EdgeIt, e, stgw) { 
 
   176 //     std::cout << e << ": " << max_flow[e] << "\n"; 
 
   178 //   std::cout << "\n";
 
   181   stGW::EdgeMap<int> pre_flow(stgw);
 
   182   MaxFlow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> > 
 
   183     pre_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, pre_flow/*, true*/);
 
   185   std::cout << "pre flow value: " << max_flow_test.flowValue() << std::endl;
 
   186   std::cout << "elapsed time: " << ts << std::endl;
 
   187 //   FOR_EACH_LOC(stGW::EdgeIt, e, stgw) { 
 
   188 //     std::cout << e << ": " << pre_flow[e] << "\n"; 
 
   190 //   std::cout << "\n";