Doc for the union-find structures.
5 #include <list_graph.h>
13 passed = passed && rc;
15 cout << "Test failed!" << endl;
21 typedef ListGraph::Node Node;
22 typedef ListGraph::Edge Edge;
33 Edge e1 = G.addEdge(s, v1);
34 Edge e2 = G.addEdge(s, v2);
35 Edge e3 = G.addEdge(v1, v2);
36 Edge e4 = G.addEdge(v2, v1);
37 Edge e5 = G.addEdge(v1, v3);
38 Edge e6 = G.addEdge(v3, v2);
39 Edge e7 = G.addEdge(v2, v4);
40 Edge e8 = G.addEdge(v4, v3);
41 Edge e9 = G.addEdge(v3, t);
42 Edge e10 = G.addEdge(v4, t);
47 cout << "DynamicPath tesztelese...\n";
49 cout << "Ures path letrehozasa" << endl;
50 typedef DynamicPath<ListGraph> LPath;
53 cout << "P.length() == " << P.length() << endl;
54 check(P.length() == 0);
56 cout << "P.from() valid? " << G.valid(P.from()) << endl;
57 check(! G.valid(P.from()));
59 cout << "Hozzaadunk ket elet..." << endl;
60 check(P.pushBack(e1));
61 check(P.pushBack(e3));
62 cout << "P.length() == " << P.length() << endl;
63 check(P.length() == 2);
65 cout << "P.from() valid? " << G.valid(P.from()) << endl;
66 check(G.valid(P.from()));
68 cout << "P.from()==s ? " << (P.from()==s) << endl;
71 cout << "Hozzaadunk egy nem illeszkedo elt." << endl;
73 cout << "Sukerult: " << rc << endl;
76 cout << "Meg 3 el hozzaadasa, nem mind elore iranyu..." << endl;
77 check(P.pushBack(e6));
78 check(P.pushBack(e8));
79 check(P.pushBack(e10));
81 cout << "P.length() == " << P.length() << endl;
82 check(P.length() == 5);
84 cout << "P.from()==s ? " << (P.from()==s) << endl;
86 cout << "P.to()==t ? " << (P.to()==t) << endl;
89 cout << "Vegpont bellitasa: " << endl;
91 cout << "Hibasra: " << rc << endl;
94 cout << "Helyesre: " << rc << endl;
97 cout << "Elek iranyitasanak ellenorzese." << endl;
98 cout << "El: " << e1 << ", G.tail(el): " << G.head(e1) << endl;
101 cout << "Vegigiteralunk az eleken." << endl;
102 typedef LPath::NodeIt NodeIt;
103 typedef LPath::EdgeIt EdgeIt;
104 EdgeIt e = P.first<EdgeIt>();
106 for(; P.valid(e); P.next(e), ++i) {
107 cout << i << ". el: " << P.graphEdge(e)
108 << ", elore el? " << P.isForward(e) << endl;
110 check(!P.isForward(e));
112 check(P.isForward(e));
116 cout << "Reszut letrehozasa: [2. el, 4. el)..." << endl;
117 LPath P2(P, P.nth<EdgeIt>(1), P.nth<EdgeIt>(3));
119 cout << "P2.length() == " << P2.length() << endl;
120 check(P2.length() == 2);
122 cout << "P2.from()==v1 ? " << (P2.from()==v1) << endl;
123 check(P2.from() == v1);
124 cout << "P2.to()==v3 ? " << (P2.to()==v3) << endl;
125 check(P2.to() == v3);
128 cout << "Reszut letrehozasa: [1. el, 6. el)..." << endl;
129 LPath P2(P, P.nth<EdgeIt>(0), P.nth<EdgeIt>(5));
131 cout << "P2.length() == " << P2.length() << endl;
132 check(P2.length() == 5);
134 cout << "P2.from()==s ? " << (P2.from()==s) << endl;
135 check(P2.from() == s);
136 cout << "P2.to()==t ? " << (P2.to()==t) << endl;
141 cout << "Ket pont altal megadott reszut letrehozasa: [2. pont, 4. pont]..."
143 LPath P2(P, P.nth<NodeIt>(1), P.nth<NodeIt>(3));
145 cout << "P2.length() == " << P2.length() << endl;
146 check(P2.length() == 2);
148 cout << "P2.from()==v1 ? " << (P2.from()==v1) << endl;
149 check(P2.from() == v1);
150 cout << "P2.to()==v3 ? " << (P2.to()==v3) << endl;
151 check(P2.to() == v3);
154 cout << "Egy pontu reszut letrehozasa: [4. pont, 4. pont]..."
156 LPath P2(P, P.nth<NodeIt>(3), P.nth<NodeIt>(3));
158 cout << "P2.length() == " << P2.length() << endl;
159 check(P2.length() == 0);
161 cout << "P2.from()==v3 ? " << (P2.from()==v3) << endl;
162 check(P2.from() == v3);
163 cout << "P2.to()==v3 ? " << (P2.to()==v3) << endl;
164 check(P2.to() == v3);
167 cout << "Forditott ut letrehozasa: [6. pont, 1. pont]..."
169 LPath P2(P, P.nth<NodeIt>(5), P.nth<NodeIt>(0));
171 cout << "P2.length() == " << P2.length() << endl;
172 check(P2.length() == 5);
174 cout << "P2.from()==t ? " << (P2.from()==t) << endl;
175 check(P2.from() == t);
176 cout << "P2.to()==s ? " << (P2.to()==s) << endl;
183 cout << "\n\n\nDirPath tesztelese...\n";
186 cout << "Ures path letrehozasa" << endl;
187 typedef DirPath<ListGraph> DPath;
190 cout << "P.length() == " << P.length() << endl;
191 check(P.length() == 0);
193 cout << "P.from() valid? " << G.valid(P.from()) << endl;
194 check(! G.valid(P.from()));
197 cout << "Builder objektum letrehozasa" << endl;
200 cout << "Hozzaadunk az elejehez ket elet..." << endl;
201 check(B.pushFront(e6));
202 check(B.pushFront(e5));
203 cout << "P.length() == " << P.length() << endl;
204 check(P.length() == 0);
206 cout << "Commitolunk..." << endl;
209 cout << "P.length() == " << P.length() << endl;
210 check(P.length() == 2);
211 cout << "P.from() valid? " << G.valid(P.from()) << endl;
212 check(G.valid(P.from()));
213 cout << "P.from()==v1 ? " << (P.from()==v1) << endl;
214 check(P.from() == v1);
216 cout << "Hozzaadunk az elejehez egy nem illeszkedo elet..." << endl;
217 check(!B.pushFront(e3));
219 cout << "Hozzaadunk a vegehez ket elet..." << endl;
220 check(B.pushBack(e7));
221 check(B.pushBack(e8));
222 cout << "P.length() == " << P.length() << endl;
223 check(P.length() == 4);
225 cout << "Hozzaadunk az elejehez meg egy elet..." << endl;
226 check(B.pushFront(e4));
227 cout << "P.length() == " << P.length() << endl;
228 check(P.length() == 4);
230 cout << "Es megvarjuk, amig megszunik a Builder...\n";
232 cout << "P.length() == " << P.length() << endl;
233 check(P.length() == 5);
234 cout << "P.from()==v2 ? " << (P.from()==v2) << endl;
235 check(P.from() == v2);
237 cout << "Vegigiteralunk az eleken." << endl;
238 typedef DPath::NodeIt NodeIt;
239 typedef DPath::EdgeIt EdgeIt;
242 for(P.first(e); P.valid(e); P.next(e), ++i) {
243 cout << i << ". el: " << e << endl;
247 cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
250 return passed ? 0 : 1;