[Lemon-commits] [lemon_svn] deba: r2851 - hugo/trunk/test
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 21:50:48 CET 2006
Author: deba
Date: Fri Jul 14 12:25:26 2006
New Revision: 2851
Modified:
hugo/trunk/test/bipartite_matching_test.cc
Log:
Using fixed bipartite graph
Modified: hugo/trunk/test/bipartite_matching_test.cc
==============================================================================
--- hugo/trunk/test/bipartite_matching_test.cc (original)
+++ hugo/trunk/test/bipartite_matching_test.cc Fri Jul 14 12:25:26 2006
@@ -2,7 +2,7 @@
#include <iostream>
#include <sstream>
-#include <lemon/list_graph.h>
+#include <lemon/smart_graph.h>
#include <lemon/bpugraph_adaptor.h>
#include <lemon/bipartite_matching.h>
@@ -16,17 +16,34 @@
using namespace std;
using namespace lemon;
-typedef ListBpUGraph Graph;
+typedef SmartBpUGraph Graph;
BPUGRAPH_TYPEDEFS(Graph);
-int main(int argc, const char *argv[]) {
+const int n = 10;
+const int m = 10;
+const int e = 52;
+const int c = 100;
+
+const int sa[e] = { 6, 5, 6, 4, 1, 0, 9, 5, 2, 4, 4, 3, 5,
+ 2, 3, 8, 3, 4, 9, 6, 9, 4, 3, 1, 5, 8,
+ 4, 8, 9, 2, 2, 3, 0, 5, 2, 3, 6, 3, 8,
+ 8, 4, 0, 9, 9, 6, 2, 1, 2, 7, 1, 9, 4};
+
+const int ta[e] = { 2, 7, 4, 8, 6, 3, 4, 1, 7, 7, 0, 1, 6,
+ 3, 2, 6, 8, 3, 5, 6, 3, 1, 8, 7, 2, 0,
+ 6, 9, 6, 7, 8, 3, 3, 4, 5, 8, 6, 4, 1,
+ 4, 3, 3, 8, 7, 7, 3, 7, 7, 3, 5, 1, 6};
+
+const int wa[e] = { 3, 99, 85, 16, 79, 52, 83, 99, 62, 6, 42, 6, 95,
+ 13, 34, 9, 5, 38, 39, 75, 99, 12, 73, 35, 93, 43,
+ 54, 91, 45, 26, 77, 47, 11, 22, 50, 74, 37, 64, 91,
+ 60, 6, 92, 29, 46, 34, 84, 67, 34, 45, 0, 39, 47};
+
+
+int main() {
Graph graph;
vector<Node> aNodes;
vector<Node> bNodes;
- int n = argc > 1 ? atoi(argv[1]) : 10;
- int m = argc > 2 ? atoi(argv[2]) : 10;
- int e = argc > 3 ? atoi(argv[3]) : (int)((n+m) * log(n+m));
- int c = argc > 4 ? atoi(argv[4]) : 100;
Graph::UEdgeMap<int> weight(graph);
@@ -44,12 +61,13 @@
bNodes.push_back(node);
}
for (int i = 0; i < e; ++i) {
- Node aNode = aNodes[urandom(n)];
- Node bNode = bNodes[urandom(m)];
+ Node aNode = aNodes[sa[i]];
+ Node bNode = bNodes[ta[i]];
UEdge uedge = graph.addEdge(aNode, bNode);
- weight[uedge] = urandom(c);
+ weight[uedge] = wa[i];
}
+
{
MaxBipartiteMatching<Graph> bpmatch(graph);
@@ -271,7 +289,6 @@
Graph::UEdgeMap<int> cost(graph);
cost = subMap(constMap<UEdge>(c), weight);
-
{
MinCostMaxBipartiteMatching<Graph> bpmatch(graph, cost);
@@ -284,6 +301,11 @@
bpmatch.matching(mm);
bpmatch.potential(pm);
+ min_cost_matching = bpmatch.matchingCost();
+ check(max_cardinality == bpmatch.matchingSize(), "WRONG SIZE");
+ check(max_cardinality * c - max_cardinality_max_weight
+ == bpmatch.matchingCost(), "WRONG SIZE");
+
for (UEdgeIt it(graph); it != INVALID; ++it) {
if (mm[it]) {
check(pm[graph.aNode(it)] + cost[it] - pm[graph.bNode(it)] == 0,
More information about the Lemon-commits
mailing list