[Lemon-commits] Alpar Juttner: Get rid of StdMap in unionfind_te...
Lemon HG
hg at lemon.cs.elte.hu
Fri Mar 21 00:16:50 CET 2008
details: http://lemon.cs.elte.hu/hg/lemon/rev/e4948ef6a4ca
changeset: 105:e4948ef6a4ca
user: Alpar Juttner <alpar [at] cs.elte.hu>
date: Thu Mar 20 22:59:58 2008 +0000
description:
Get rid of StdMap in unionfind_test.cc
diffstat:
1 file changed, 45 insertions(+), 55 deletions(-)
test/unionfind_test.cc | 100 +++++++++++++++++++++---------------------------
diffs (146 lines):
diff -r b68a7e348e00 -r e4948ef6a4ca test/unionfind_test.cc
--- a/test/unionfind_test.cc Fri Feb 29 11:01:39 2008 +0000
+++ b/test/unionfind_test.cc Thu Mar 20 22:59:58 2008 +0000
@@ -18,6 +18,7 @@
#include <iostream>
+#include <lemon/list_graph.h>
#include <lemon/maps.h>
#include <lemon/unionfind.h>
#include "test_tools.h"
@@ -25,90 +26,79 @@ using namespace lemon;
using namespace lemon;
using namespace std;
-typedef UnionFindEnum<StdMap<int, int> > UFE;
-
-void print(UFE const &ufe) {
- cout << "Print the classes of the structure:" << endl;
- int i = 1;
- for (UFE::ClassIt cit(ufe); cit != INVALID; ++cit) {
- cout << " " << i << " (" << cit << "):" << flush;
- for (UFE::ItemIt iit(ufe, cit); iit != INVALID; ++iit) {
- cout << " " << iit << flush;
- }
- cout << endl;
- i++;
- }
- cout << "done" << endl;
-}
-
+typedef UnionFindEnum<ListGraph::NodeMap<int> > UFE;
int main() {
- StdMap<int, int> base;
+ ListGraph g;
+ ListGraph::NodeMap<int> base(g);
UFE U(base);
+ vector<ListGraph::Node> n;
+
+ for(int i=0;i<20;i++) n.push_back(g.addNode());
- U.insert(1);
- U.insert(2);
+ U.insert(n[1]);
+ U.insert(n[2]);
- check(U.join(1,2) != -1,"Test failed.");
+ check(U.join(n[1],n[2]) != -1,"Test failed.");
- U.insert(3);
- U.insert(4);
- U.insert(5);
- U.insert(6);
- U.insert(7);
+ U.insert(n[3]);
+ U.insert(n[4]);
+ U.insert(n[5]);
+ U.insert(n[6]);
+ U.insert(n[7]);
- check(U.join(1,4) != -1,"Test failed.");
- check(U.join(2,4) == -1,"Test failed.");
- check(U.join(3,5) != -1,"Test failed.");
+ check(U.join(n[1],n[4]) != -1,"Test failed.");
+ check(U.join(n[2],n[4]) == -1,"Test failed.");
+ check(U.join(n[3],n[5]) != -1,"Test failed.");
- U.insert(8,U.find(5));
+ U.insert(n[8],U.find(n[5]));
- check(U.size(U.find(4)) == 3,"Test failed.");
- check(U.size(U.find(5)) == 3,"Test failed.");
- check(U.size(U.find(6)) == 1,"Test failed.");
- check(U.size(U.find(2)) == 3,"Test failed.");
+ check(U.size(U.find(n[4])) == 3,"Test failed.");
+ check(U.size(U.find(n[5])) == 3,"Test failed.");
+ check(U.size(U.find(n[6])) == 1,"Test failed.");
+ check(U.size(U.find(n[2])) == 3,"Test failed.");
- U.insert(9);
- U.insert(10,U.find(9));
+ U.insert(n[9]);
+ U.insert(n[10],U.find(n[9]));
- check(U.join(8,10) != -1,"Test failed.");
+ check(U.join(n[8],n[10]) != -1,"Test failed.");
- check(U.size(U.find(4)) == 3,"Test failed.");
- check(U.size(U.find(9)) == 5,"Test failed.");
+ check(U.size(U.find(n[4])) == 3,"Test failed.");
+ check(U.size(U.find(n[9])) == 5,"Test failed.");
- check(U.size(U.find(8)) == 5,"Test failed.");
+ check(U.size(U.find(n[8])) == 5,"Test failed.");
- U.erase(9);
- U.erase(1);
+ U.erase(n[9]);
+ U.erase(n[1]);
- check(U.size(U.find(10)) == 4,"Test failed.");
- check(U.size(U.find(2)) == 2,"Test failed.");
+ check(U.size(U.find(n[10])) == 4,"Test failed.");
+ check(U.size(U.find(n[2])) == 2,"Test failed.");
- U.erase(6);
- U.split(U.find(8));
+ U.erase(n[6]);
+ U.split(U.find(n[8]));
- check(U.size(U.find(4)) == 2,"Test failed.");
- check(U.size(U.find(3)) == 1,"Test failed.");
- check(U.size(U.find(2)) == 2,"Test failed.");
+ check(U.size(U.find(n[4])) == 2,"Test failed.");
+ check(U.size(U.find(n[3])) == 1,"Test failed.");
+ check(U.size(U.find(n[2])) == 2,"Test failed.");
- check(U.join(3,4) != -1,"Test failed.");
- check(U.join(2,4) == -1,"Test failed.");
+ check(U.join(n[3],n[4]) != -1,"Test failed.");
+ check(U.join(n[2],n[4]) == -1,"Test failed.");
- check(U.size(U.find(4)) == 3,"Test failed.");
- check(U.size(U.find(3)) == 3,"Test failed.");
- check(U.size(U.find(2)) == 3,"Test failed.");
+ check(U.size(U.find(n[4])) == 3,"Test failed.");
+ check(U.size(U.find(n[3])) == 3,"Test failed.");
+ check(U.size(U.find(n[2])) == 3,"Test failed.");
- U.eraseClass(U.find(4));
- U.eraseClass(U.find(7));
+ U.eraseClass(U.find(n[4]));
+ U.eraseClass(U.find(n[7]));
return 0;
}
More information about the Lemon-commits
mailing list