benchmark/swap_bipartite_bench.cc
changeset 2207 75a29ac69c19
parent 2130 244e108de26f
child 2208 37b5c870a953
     1.1 --- a/benchmark/swap_bipartite_bench.cc	Wed Sep 06 11:39:22 2006 +0000
     1.2 +++ b/benchmark/swap_bipartite_bench.cc	Thu Sep 07 13:27:16 2006 +0000
     1.3 @@ -3,12 +3,13 @@
     1.4  #include <sstream>
     1.5  
     1.6  #include <lemon/smart_graph.h>
     1.7 +#include <lemon/list_graph.h>
     1.8  
     1.9  #include <lemon/bpugraph_adaptor.h>
    1.10  #include <lemon/bipartite_matching.h>
    1.11  
    1.12  #include <lemon/graph_utils.h>
    1.13 -#include <lemon/xy.h>
    1.14 +#include <lemon/dim2.h>
    1.15  #include <lemon/graph_to_eps.h>
    1.16  
    1.17  #include <lemon/time_measure.h>
    1.18 @@ -17,6 +18,7 @@
    1.19  using namespace lemon;
    1.20  
    1.21  typedef SmartBpUGraph Graph;
    1.22 +typedef ListBpUGraph LGraph;
    1.23  BPUGRAPH_TYPEDEFS(Graph);
    1.24  
    1.25  int _urandom_init() {
    1.26 @@ -41,24 +43,36 @@
    1.27      int s = 100;
    1.28      
    1.29      Timer nt(false), st(false);
    1.30 +    Timer lnt(false), lst(false);
    1.31      
    1.32      for (int i = 0; i < s; ++i) {
    1.33        Graph graph;
    1.34 +      LGraph lgraph;
    1.35        vector<Node> aNodes;
    1.36        vector<Node> bNodes;  
    1.37 +      vector<LGraph::Node> laNodes;
    1.38 +      vector<LGraph::Node> lbNodes;  
    1.39        
    1.40        for (int i = 0; i < n; ++i) {
    1.41          Node node = graph.addANode();
    1.42          aNodes.push_back(node);
    1.43 +        LGraph::Node lnode = lgraph.addANode();
    1.44 +        laNodes.push_back(lnode);
    1.45        }
    1.46        for (int i = 0; i < m; ++i) {
    1.47          Node node = graph.addBNode();
    1.48          bNodes.push_back(node);
    1.49 +        LGraph::Node lnode = lgraph.addBNode();
    1.50 +        lbNodes.push_back(lnode);
    1.51        }
    1.52        for (int i = 0; i < e; ++i) {
    1.53 -        Node aNode = aNodes[urandom(n)];
    1.54 -        Node bNode = bNodes[urandom(m)];
    1.55 +        int a,b;
    1.56 +	Node aNode = aNodes[a=urandom(n)];
    1.57 +        Node bNode = bNodes[b=urandom(m)];
    1.58          graph.addEdge(aNode, bNode);
    1.59 +	LGraph::Node laNode = laNodes[a];
    1.60 +        LGraph::Node lbNode = lbNodes[b];
    1.61 +        lgraph.addEdge(laNode, lbNode);
    1.62        }
    1.63  
    1.64        {
    1.65 @@ -81,11 +95,32 @@
    1.66          bpmatch.start();
    1.67          st.stop();
    1.68          
    1.69 +      }                 
    1.70 +      {
    1.71 +        MaxBipartiteMatching<LGraph> bpmatch(lgraph);
    1.72 +        
    1.73 +        lnt.start();
    1.74 +        bpmatch.init();
    1.75 +        bpmatch.start();
    1.76 +        lnt.stop();
    1.77 +        
    1.78        }
    1.79 -                  
    1.80 -    }
    1.81  
    1.82 -    cout << k * 100 << ' ' << nt.realTime() << ' ' << st.realTime() << endl;
    1.83 +      {
    1.84 +        typedef SwapBpUGraphAdaptor<LGraph> SGraph;
    1.85 +        SGraph sgraph(lgraph);
    1.86 +        MaxBipartiteMatching<SGraph> bpmatch(sgraph);
    1.87 +
    1.88 +        lst.start();
    1.89 +        bpmatch.init();
    1.90 +        bpmatch.start();
    1.91 +        lst.stop();
    1.92 +        
    1.93 +      }
    1.94 +     }
    1.95 +
    1.96 +    cout << k * 100 << ' ' << nt.realTime() << ' ' << st.realTime()
    1.97 +	 << ' ' << lnt.realTime() << ' ' << lst.realTime()<< endl;
    1.98  
    1.99    }
   1.100