ResGraphWrapper mods.
4 #include <hugo/unionfind.h>
12 passed = passed && rc;
14 cout << "Test failed!" << endl;
19 class BaseMap : public StdMap<int,T> {};
21 typedef UnionFindEnum<int, BaseMap> UFE;
23 void print(UFE const &ufe) {
25 cout << "printing the classes of the structure:" << endl;
27 for (ufe.first(cit); ufe.valid(cit); ufe.next(cit)) {
28 cout << " " << i << " (" << cit << "):" << flush;
30 for (ufe.first(iit, cit); ufe.valid(iit); ufe.next(iit)) {
31 cout << " " << iit << flush;
36 cout << "done" << endl;
46 cout << "Inserting 1..." << endl;
50 cout << "Inserting 2..." << endl;
54 cout << "Joining 1 and 2..." << endl;
58 cout << "Inserting 3, 4, 5, 6, 7..." << endl;
66 cout << "Joining 1 - 4, 2 - 4 and 3 - 5 ..." << endl;
72 cout << "Inserting 8 to the component of 5 ..." << endl;
76 cout << "size of the class of 4: " << U.size(4) << endl;
77 check(U.size(4) == 3);
78 cout << "size of the class of 5: " << U.size(5) << endl;
79 check(U.size(5) == 3);
80 cout << "size of the class of 6: " << U.size(6) << endl;
81 check(U.size(6) == 1);
82 cout << "size of the class of 2: " << U.size(2) << endl;
83 check(U.size(2) == 3);
85 cout << "Inserting 9 ..." << endl;
88 cout << "Inserting 10 to the component of 9 ..." << endl;
92 cout << "Joining 8 and 10..." << endl;
96 cout << "Move 9 to the class of 4 ..." << endl;
100 cout << "Move 9 to the class of 2 ..." << endl;
104 cout << "size of the class of 4: " << U.size(4) << endl;
105 check(U.size(4) == 4);
106 cout << "size of the class of 9: " << U.size(9) << endl;
107 check(U.size(9) == 4);
109 cout << "Move 5 to the class of 6 ..." << endl;
113 cout << "size of the class of 5: " << U.size(5) << endl;
114 check(U.size(5) == 2);
115 cout << "size of the class of 8: " << U.size(8) << endl;
116 check(U.size(8) == 3);
118 cout << "Move 7 to the class of 10 ..." << endl;
122 cout << "size of the class of 7: " << U.size(7) << endl;
123 check(U.size(7) == 4);
125 cout <<"erase 9: " << endl;
129 cout <<"erase 1: " << endl;
133 cout << "size of the class of 4: " << U.size(4) << endl;
134 check(U.size(4) == 2);
135 cout << "size of the class of 2: " << U.size(2) << endl;
136 check(U.size(2) == 2);
139 cout <<"erase 1: " << endl;
143 cout <<"erase 6: " << endl;
147 cout << "split the class of 8: " << endl;
152 cout << "size of the class of 4: " << U.size(4) << endl;
153 check(U.size(4) == 2);
154 cout << "size of the class of 3: " << U.size(3) << endl;
155 check(U.size(3) == 1);
156 cout << "size of the class of 2: " << U.size(2) << endl;
157 check(U.size(2) == 2);
160 cout << "Joining 3 - 4 and 2 - 4 ..." << endl;
166 cout << "size of the class of 4: " << U.size(4) << endl;
167 check(U.size(4) == 3);
168 cout << "size of the class of 3: " << U.size(3) << endl;
169 check(U.size(3) == 3);
170 cout << "size of the class of 2: " << U.size(2) << endl;
171 check(U.size(2) == 3);
173 cout << "makeRep(4)" << endl;
176 cout << "makeRep(3)" << endl;
179 cout << "makeRep(2)" << endl;
183 cout << "size of the class of 4: " << U.size(4) << endl;
184 check(U.size(4) == 3);
185 cout << "size of the class of 3: " << U.size(3) << endl;
186 check(U.size(3) == 3);
187 cout << "size of the class of 2: " << U.size(2) << endl;
188 check(U.size(2) == 3);
191 cout << "eraseClass 4 ..." << endl;
195 cout << "eraseClass 7 ..." << endl;
199 cout << "done" << endl;
201 cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
204 return passed ? 0 : 1;