/* -*- C++ -*- * * This file is a part of LEMON, a generic C++ optimization library * * Copyright (C) 2003-2008 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport * (Egervary Research Group on Combinatorial Optimization, EGRES). * * Permission to use, modify and distribute this software is granted * provided that this copyright notice appears in all copies. For * precise terms see the accompanying LICENSE file. * * This software is provided "AS IS" with no warranty of any kind, * express or implied, and with no claim as to its suitability for any * purpose. * */ #include #include #include #include #include #include #include #include #include #include #include using namespace std; using namespace lemon; typedef SmartBpUGraph Graph; typedef ListBpUGraph LGraph; BPUGRAPH_TYPEDEFS(Graph); int main() { for (int k = 1; k < 100; ++k) { int n = k * 100; int m = (100 - k) * 100; int e = 20000; int s = 100; Timer nt(false), st(false); Timer lnt(false), lst(false); for (int i = 0; i < s; ++i) { Graph graph; LGraph lgraph; vector aNodes; vector bNodes; vector laNodes; vector lbNodes; for (int j = 0; j < n; ++j) { Node node = graph.addANode(); aNodes.push_back(node); LGraph::Node lnode = lgraph.addANode(); laNodes.push_back(lnode); } for (int j = 0; j < m; ++j) { Node node = graph.addBNode(); bNodes.push_back(node); LGraph::Node lnode = lgraph.addBNode(); lbNodes.push_back(lnode); } for (int j = 0; j < e; ++j) { int a,b; Node aNode = aNodes[a=rnd[n]]; Node bNode = bNodes[b=rnd[m]]; graph.addEdge(aNode, bNode); LGraph::Node laNode = laNodes[a]; LGraph::Node lbNode = lbNodes[b]; lgraph.addEdge(laNode, lbNode); } { MaxBipartiteMatching bpmatch(graph); nt.start(); bpmatch.init(); bpmatch.start(); nt.stop(); } { typedef SwapBpUGraphAdaptor SGraph; SGraph sgraph(graph); MaxBipartiteMatching bpmatch(sgraph); st.start(); bpmatch.init(); bpmatch.start(); st.stop(); } { MaxBipartiteMatching bpmatch(lgraph); lnt.start(); bpmatch.init(); bpmatch.start(); lnt.stop(); } { typedef SwapBpUGraphAdaptor SGraph; SGraph sgraph(lgraph); MaxBipartiteMatching bpmatch(sgraph); lst.start(); bpmatch.init(); bpmatch.start(); lst.stop(); } } cout << k * 100 << ' ' << nt.realTime() << ' ' << st.realTime() << ' ' << lnt.realTime() << ' ' << lst.realTime()<< endl; } return 0; }