src/work/marci/bipartite_matching_try_2.cc
changeset 500 1a45623b4796
parent 499 767f3da8ce0e
child 501 20e4941a354a
     1.1 --- a/src/work/marci/bipartite_matching_try_2.cc	Fri Apr 30 17:10:01 2004 +0000
     1.2 +++ b/src/work/marci/bipartite_matching_try_2.cc	Fri Apr 30 17:48:50 2004 +0000
     1.3 @@ -63,7 +63,7 @@
     1.4    std::cout << "number of edges=";
     1.5    std::cin >> m; 
     1.6    
     1.7 -
     1.8 +  std::cout << "Generatig a random bipartite graph..." << std::endl;
     1.9    for (int i=0; i<a; ++i) s_nodes.push_back(g.addNode(false));
    1.10    for (int i=0; i<b; ++i) t_nodes.push_back(g.addNode(true));
    1.11  
    1.12 @@ -76,24 +76,44 @@
    1.13    FOR_EACH_LOC(EdgeIt, e, g) std::cout << e << " ";
    1.14    std::cout << std::endl;
    1.15  
    1.16 +  std::cout << "Nodes in T:" << std::endl;
    1.17 +  FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, g.T_CLASS) std::cout << v << " ";
    1.18 +  std::cout << std::endl;
    1.19 +  std::cout << "Nodes in S:" << std::endl;
    1.20 +  FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, g.S_CLASS) std::cout << v << " ";
    1.21 +  std::cout << std::endl;
    1.22 +
    1.23 +  std::cout << "Erasing the first node..." << std::endl;
    1.24 +  NodeIt n;
    1.25 +  g.first(n);
    1.26 +  g.erase(n);
    1.27 +  std::cout << "Nodes of the bipartite graph:" << std::endl;
    1.28 +  FOR_EACH_GLOB(n, g) std::cout << n << " ";
    1.29 +  std::cout << std::endl;
    1.30 +
    1.31 +  std::cout << "Nodes in T:" << std::endl;
    1.32 +  FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, g.T_CLASS) std::cout << v << " ";
    1.33 +  std::cout << std::endl;
    1.34 +  std::cout << "Nodes in S:" << std::endl;
    1.35 +  FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, g.S_CLASS) std::cout << v << " ";
    1.36 +  std::cout << std::endl;
    1.37 +
    1.38    typedef stGraphWrapper<Graph> stGW;
    1.39    stGW stgw(g);
    1.40    ConstMap<stGW::Edge, int> const1map(1);
    1.41  
    1.42 -
    1.43 -
    1.44 -
    1.45    Timer ts;
    1.46    ts.reset();
    1.47    stGW::EdgeMap<int> flow(stgw);
    1.48    MaxFlow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> > 
    1.49      max_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, flow);
    1.50 +  max_flow_test.run();
    1.51  //  while (max_flow_test.augmentOnShortestPath()) { }
    1.52 -  typedef ListGraph MutableGraph;
    1.53 +//  typedef ListGraph MutableGraph;
    1.54  //  while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) {
    1.55 -  while (max_flow_test.augmentOnBlockingFlow2()) {
    1.56 -   std::cout << max_flow_test.flowValue() << std::endl;
    1.57 -  }
    1.58 +//  while (max_flow_test.augmentOnBlockingFlow2()) {
    1.59 +//   std::cout << max_flow_test.flowValue() << std::endl;
    1.60 +//  }
    1.61    std::cout << "max flow value: " << max_flow_test.flowValue() << std::endl;
    1.62    std::cout << "elapsed time: " << ts << std::endl;
    1.63    FOR_EACH_LOC(stGW::EdgeIt, e, stgw) { 
    1.64 @@ -101,17 +121,5 @@
    1.65    }
    1.66    std::cout << std::endl;
    1.67  
    1.68 -  ts.reset();
    1.69 -  stGW::EdgeMap<int> pre_flow(stgw);
    1.70 -  MaxFlow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> > 
    1.71 -    pre_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, pre_flow/*, true*/);
    1.72 -  pre_flow_test.run();
    1.73 -  std::cout << "pre flow value: " << max_flow_test.flowValue() << std::endl;
    1.74 -  std::cout << "elapsed time: " << ts << std::endl;
    1.75 -//   FOR_EACH_LOC(stGW::EdgeIt, e, stgw) { 
    1.76 -//     std::cout << e << ": " << pre_flow[e] << "\n"; 
    1.77 -//   }
    1.78 -//   std::cout << "\n";
    1.79 -
    1.80    return 0;
    1.81  }