5 #include <lemon/smart_graph.h>
6 #include <lemon/list_graph.h>
8 #include <lemon/bpugraph_adaptor.h>
9 #include <lemon/bipartite_matching.h>
11 #include <lemon/graph_utils.h>
12 #include <lemon/dim2.h>
13 #include <lemon/graph_to_eps.h>
15 #include <lemon/time_measure.h>
18 using namespace lemon;
20 typedef SmartBpUGraph Graph;
21 typedef ListBpUGraph LGraph;
22 BPUGRAPH_TYPEDEFS(Graph);
31 static int seed = _urandom_init();
32 ignore_unused_variable_warning(seed);
33 return (int)(rand() / (1.0 + RAND_MAX) * n);
38 for (int k = 1; k < 100; ++k) {
41 int m = (100 - k) * 100;
45 Timer nt(false), st(false);
46 Timer lnt(false), lst(false);
48 for (int i = 0; i < s; ++i) {
53 vector<LGraph::Node> laNodes;
54 vector<LGraph::Node> lbNodes;
56 for (int i = 0; i < n; ++i) {
57 Node node = graph.addANode();
58 aNodes.push_back(node);
59 LGraph::Node lnode = lgraph.addANode();
60 laNodes.push_back(lnode);
62 for (int i = 0; i < m; ++i) {
63 Node node = graph.addBNode();
64 bNodes.push_back(node);
65 LGraph::Node lnode = lgraph.addBNode();
66 lbNodes.push_back(lnode);
68 for (int i = 0; i < e; ++i) {
70 Node aNode = aNodes[a=urandom(n)];
71 Node bNode = bNodes[b=urandom(m)];
72 graph.addEdge(aNode, bNode);
73 LGraph::Node laNode = laNodes[a];
74 LGraph::Node lbNode = lbNodes[b];
75 lgraph.addEdge(laNode, lbNode);
79 MaxBipartiteMatching<Graph> bpmatch(graph);
89 typedef SwapBpUGraphAdaptor<Graph> SGraph;
91 MaxBipartiteMatching<SGraph> bpmatch(sgraph);
100 MaxBipartiteMatching<LGraph> bpmatch(lgraph);
110 typedef SwapBpUGraphAdaptor<LGraph> SGraph;
111 SGraph sgraph(lgraph);
112 MaxBipartiteMatching<SGraph> bpmatch(sgraph);
122 cout << k * 100 << ' ' << nt.realTime() << ' ' << st.realTime()
123 << ' ' << lnt.realTime() << ' ' << lst.realTime()<< endl;