diff -r f50c8c191cbd -r 59769591eb60 benchmark/swap_bipartite_bench.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/benchmark/swap_bipartite_bench.cc Mon May 15 09:49:51 2006 +0000 @@ -0,0 +1,92 @@ +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include + +#include + +using namespace std; +using namespace lemon; + +typedef SmartBpUGraph Graph; +BPUGRAPH_TYPEDEFS(Graph); + +int _urandom_init() { + int seed = time(0); + srand(seed); + return seed; +} + +int urandom(int n) { + static int seed = _urandom_init(); + return (int)(rand() / (1.0 + RAND_MAX) * n); +} + +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); + + for (int i = 0; i < s; ++i) { + Graph graph; + vector aNodes; + vector bNodes; + + for (int i = 0; i < n; ++i) { + Node node = graph.addANode(); + aNodes.push_back(node); + } + for (int i = 0; i < m; ++i) { + Node node = graph.addBNode(); + bNodes.push_back(node); + } + for (int i = 0; i < e; ++i) { + Node aNode = aNodes[urandom(n)]; + Node bNode = bNodes[urandom(m)]; + graph.addEdge(aNode, bNode); + } + + { + 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(); + + } + + } + + cout << k * 100 << ' ' << nt.realTime() << ' ' << st.realTime() << endl; + + } + + return 0; +}