src/work/marci/bipartite_matching_try_2.cc
changeset 510 72143568cadc
parent 501 20e4941a354a
child 555 995bc1f1a3ce
equal deleted inserted replaced
3:7229f361d823 4:60de6d182999
    70   random_init();
    70   random_init();
    71   for(int i=0; i<m; ++i) {
    71   for(int i=0; i<m; ++i) {
    72     g.addEdge(s_nodes[random(a)], t_nodes[random(b)]);
    72     g.addEdge(s_nodes[random(a)], t_nodes[random(b)]);
    73   }
    73   }
    74 
    74 
    75   std::cout << "Edges of the bipartite graph:" << std::endl;
    75 //   std::cout << "Edges of the bipartite graph:" << std::endl;
    76   FOR_EACH_LOC(EdgeIt, e, g) std::cout << e << " ";
    76 //   FOR_EACH_LOC(EdgeIt, e, g) std::cout << e << " ";
    77   std::cout << std::endl;
    77 //   std::cout << std::endl;
    78 
    78 
    79   std::cout << "Nodes:" << std::endl;
    79 //   std::cout << "Nodes:" << std::endl;
    80   FOR_EACH_LOC(Graph::NodeIt, v, g) std::cout << v << " ";
    80 //   FOR_EACH_LOC(Graph::NodeIt, v, g) std::cout << v << " ";
    81   std::cout << std::endl;
    81 //   std::cout << std::endl;
    82   std::cout << "Nodes in T:" << std::endl;
    82 //   std::cout << "Nodes in T:" << std::endl;
    83   FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::T_CLASS) std::cout << v << " ";
    83 //   FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::T_CLASS) std::cout << v << " ";
    84   std::cout << std::endl;
    84 //   std::cout << std::endl;
    85   std::cout << "Nodes in S:" << std::endl;
    85 //   std::cout << "Nodes in S:" << std::endl;
    86   FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::S_CLASS) std::cout << v << " ";
    86 //   FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::S_CLASS) std::cout << v << " ";
    87   std::cout << std::endl;
    87 //   std::cout << std::endl;
    88 
    88 
    89   std::cout << "Erasing the first node..." << std::endl;
    89 //   std::cout << "Erasing the first node..." << std::endl;
    90   NodeIt n;
    90 //   NodeIt n;
    91   g.first(n);
    91 //   g.first(n);
    92   g.erase(n);
    92 //   g.erase(n);
    93   std::cout << "Nodes of the bipartite graph:" << std::endl;
    93 //   std::cout << "Nodes of the bipartite graph:" << std::endl;
    94   FOR_EACH_GLOB(n, g) std::cout << n << " ";
    94 //   FOR_EACH_GLOB(n, g) std::cout << n << " ";
    95   std::cout << std::endl;
    95 //   std::cout << std::endl;
    96 
    96 
    97   std::cout << "Nodes in T:" << std::endl;
    97 //   std::cout << "Nodes in T:" << std::endl;
    98   FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::T_CLASS) std::cout << v << " ";
    98 //   FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::T_CLASS) std::cout << v << " ";
    99   std::cout << std::endl;
    99 //   std::cout << std::endl;
   100   std::cout << "Nodes in S:" << std::endl;
   100 //   std::cout << "Nodes in S:" << std::endl;
   101   FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::S_CLASS) std::cout << v << " ";
   101 //   FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::S_CLASS) std::cout << v << " ";
   102   std::cout << std::endl;
   102 //   std::cout << std::endl;
   103 
   103 
   104   typedef stGraphWrapper<Graph> stGW;
   104   typedef stGraphWrapper<Graph> stGW;
   105   stGW stgw(g);
   105   stGW stgw(g);
   106   ConstMap<stGW::Edge, int> const1map(1);
   106   ConstMap<stGW::Edge, int> const1map(1);
   107 
   107 
   117 //  while (max_flow_test.augmentOnBlockingFlow2()) {
   117 //  while (max_flow_test.augmentOnBlockingFlow2()) {
   118 //   std::cout << max_flow_test.flowValue() << std::endl;
   118 //   std::cout << max_flow_test.flowValue() << std::endl;
   119 //  }
   119 //  }
   120   std::cout << "max flow value: " << max_flow_test.flowValue() << std::endl;
   120   std::cout << "max flow value: " << max_flow_test.flowValue() << std::endl;
   121   std::cout << "elapsed time: " << ts << std::endl;
   121   std::cout << "elapsed time: " << ts << std::endl;
   122   FOR_EACH_LOC(stGW::EdgeIt, e, stgw) { 
   122 //   FOR_EACH_LOC(stGW::EdgeIt, e, stgw) { 
   123     if (flow[e]) std::cout << e << std::endl; 
   123 //     if (flow[e]) std::cout << e << std::endl; 
   124   }
   124 //   }
   125   std::cout << std::endl;
   125 //   std::cout << std::endl;
   126 
   126 
   127   return 0;
   127   return 0;
   128 }
   128 }