1.1 --- a/test/bipartite_matching_test.cc Fri Jul 14 09:37:48 2006 +0000
1.2 +++ b/test/bipartite_matching_test.cc Fri Jul 14 10:25:26 2006 +0000
1.3 @@ -2,7 +2,7 @@
1.4 #include <iostream>
1.5 #include <sstream>
1.6
1.7 -#include <lemon/list_graph.h>
1.8 +#include <lemon/smart_graph.h>
1.9
1.10 #include <lemon/bpugraph_adaptor.h>
1.11 #include <lemon/bipartite_matching.h>
1.12 @@ -16,17 +16,34 @@
1.13 using namespace std;
1.14 using namespace lemon;
1.15
1.16 -typedef ListBpUGraph Graph;
1.17 +typedef SmartBpUGraph Graph;
1.18 BPUGRAPH_TYPEDEFS(Graph);
1.19
1.20 -int main(int argc, const char *argv[]) {
1.21 +const int n = 10;
1.22 +const int m = 10;
1.23 +const int e = 52;
1.24 +const int c = 100;
1.25 +
1.26 +const int sa[e] = { 6, 5, 6, 4, 1, 0, 9, 5, 2, 4, 4, 3, 5,
1.27 + 2, 3, 8, 3, 4, 9, 6, 9, 4, 3, 1, 5, 8,
1.28 + 4, 8, 9, 2, 2, 3, 0, 5, 2, 3, 6, 3, 8,
1.29 + 8, 4, 0, 9, 9, 6, 2, 1, 2, 7, 1, 9, 4};
1.30 +
1.31 +const int ta[e] = { 2, 7, 4, 8, 6, 3, 4, 1, 7, 7, 0, 1, 6,
1.32 + 3, 2, 6, 8, 3, 5, 6, 3, 1, 8, 7, 2, 0,
1.33 + 6, 9, 6, 7, 8, 3, 3, 4, 5, 8, 6, 4, 1,
1.34 + 4, 3, 3, 8, 7, 7, 3, 7, 7, 3, 5, 1, 6};
1.35 +
1.36 +const int wa[e] = { 3, 99, 85, 16, 79, 52, 83, 99, 62, 6, 42, 6, 95,
1.37 + 13, 34, 9, 5, 38, 39, 75, 99, 12, 73, 35, 93, 43,
1.38 + 54, 91, 45, 26, 77, 47, 11, 22, 50, 74, 37, 64, 91,
1.39 + 60, 6, 92, 29, 46, 34, 84, 67, 34, 45, 0, 39, 47};
1.40 +
1.41 +
1.42 +int main() {
1.43 Graph graph;
1.44 vector<Node> aNodes;
1.45 vector<Node> bNodes;
1.46 - int n = argc > 1 ? atoi(argv[1]) : 10;
1.47 - int m = argc > 2 ? atoi(argv[2]) : 10;
1.48 - int e = argc > 3 ? atoi(argv[3]) : (int)((n+m) * log(n+m));
1.49 - int c = argc > 4 ? atoi(argv[4]) : 100;
1.50
1.51 Graph::UEdgeMap<int> weight(graph);
1.52
1.53 @@ -44,12 +61,13 @@
1.54 bNodes.push_back(node);
1.55 }
1.56 for (int i = 0; i < e; ++i) {
1.57 - Node aNode = aNodes[urandom(n)];
1.58 - Node bNode = bNodes[urandom(m)];
1.59 + Node aNode = aNodes[sa[i]];
1.60 + Node bNode = bNodes[ta[i]];
1.61 UEdge uedge = graph.addEdge(aNode, bNode);
1.62 - weight[uedge] = urandom(c);
1.63 + weight[uedge] = wa[i];
1.64 }
1.65
1.66 +
1.67 {
1.68 MaxBipartiteMatching<Graph> bpmatch(graph);
1.69
1.70 @@ -271,7 +289,6 @@
1.71
1.72 Graph::UEdgeMap<int> cost(graph);
1.73 cost = subMap(constMap<UEdge>(c), weight);
1.74 -
1.75 {
1.76
1.77 MinCostMaxBipartiteMatching<Graph> bpmatch(graph, cost);
1.78 @@ -284,6 +301,11 @@
1.79 bpmatch.matching(mm);
1.80 bpmatch.potential(pm);
1.81
1.82 + min_cost_matching = bpmatch.matchingCost();
1.83 + check(max_cardinality == bpmatch.matchingSize(), "WRONG SIZE");
1.84 + check(max_cardinality * c - max_cardinality_max_weight
1.85 + == bpmatch.matchingCost(), "WRONG SIZE");
1.86 +
1.87 for (UEdgeIt it(graph); it != INVALID; ++it) {
1.88 if (mm[it]) {
1.89 check(pm[graph.aNode(it)] + cost[it] - pm[graph.bNode(it)] == 0,