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);
46 cout << "Ures path letrehozasa" << endl;
47 typedef Path<ListGraph> LPath;
50 cout << "P.length() == " << P.length() << endl;
51 check(P.length() == 0);
53 cout << "P.from() valid? " << G.valid(P.from()) << endl;
54 check(! G.valid(P.from()));
56 cout << "Hozzaadunk ket elet..." << endl;
57 check(P.pushBack(e1));
58 check(P.pushBack(e3));
59 cout << "P.length() == " << P.length() << endl;
60 check(P.length() == 2);
62 cout << "P.from() valid? " << G.valid(P.from()) << endl;
63 check(G.valid(P.from()));
65 cout << "P.from()==s ? " << (P.from()==s) << endl;
68 cout << "Hozzaadunk egy nem illeszkedo elt." << endl;
70 cout << "Sukerult: " << rc << endl;
73 cout << "Meg 3 el hozzaadasa, nem mind elore iranyu..." << endl;
74 check(P.pushBack(e6));
75 check(P.pushBack(e8));
76 check(P.pushBack(e10));
78 cout << "P.length() == " << P.length() << endl;
79 check(P.length() == 5);
81 cout << "P.from()==s ? " << (P.from()==s) << endl;
83 cout << "P.to()==t ? " << (P.to()==t) << endl;
86 cout << "Vegpont bellitasa: " << endl;
88 cout << "Hibasra: " << rc << endl;
91 cout << "Helyesre: " << rc << endl;
94 cout << "Elek iranyitasanak ellenorzese." << endl;
95 cout << "El: " << e1 << ", G.tail(el): " << G.head(e1) << endl;
98 cout << "Vegigiteralunk az eleken." << endl;
99 typedef LPath::NodeIt NodeIt;
100 typedef LPath::EdgeIt EdgeIt;
101 EdgeIt e = P.first<EdgeIt>();
103 for(; P.valid(e); P.next(e), ++i) {
104 cout << i << ". el: " << P.graphEdge(e)
105 << ", elore el? " << P.isForward(e) << endl;
107 check(!P.isForward(e));
109 check(P.isForward(e));
113 cout << "Reszut letrehozasa: [2. el, 4. el)..." << endl;
114 LPath P2(P, P.nth<EdgeIt>(1), P.nth<EdgeIt>(3));
116 cout << "P2.length() == " << P2.length() << endl;
117 check(P2.length() == 2);
119 cout << "P2.from()==v1 ? " << (P2.from()==v1) << endl;
120 check(P2.from() == v1);
121 cout << "P2.to()==v3 ? " << (P2.to()==v3) << endl;
122 check(P2.to() == v3);
125 cout << "Reszut letrehozasa: [1. el, 6. el)..." << endl;
126 LPath P2(P, P.nth<EdgeIt>(0), P.nth<EdgeIt>(5));
128 cout << "P2.length() == " << P2.length() << endl;
129 check(P2.length() == 5);
131 cout << "P2.from()==s ? " << (P2.from()==s) << endl;
132 check(P2.from() == s);
133 cout << "P2.to()==t ? " << (P2.to()==t) << endl;
138 cout << "Ket pont altal megadott reszut letrehozasa: [2. pont, 4. pont]..."
140 LPath P2(P, P.nth<NodeIt>(1), P.nth<NodeIt>(3));
142 cout << "P2.length() == " << P2.length() << endl;
143 check(P2.length() == 2);
145 cout << "P2.from()==v1 ? " << (P2.from()==v1) << endl;
146 check(P2.from() == v1);
147 cout << "P2.to()==v3 ? " << (P2.to()==v3) << endl;
148 check(P2.to() == v3);
151 cout << "Egy pontu reszut letrehozasa: [4. pont, 4. pont]..."
153 LPath P2(P, P.nth<NodeIt>(3), P.nth<NodeIt>(3));
155 cout << "P2.length() == " << P2.length() << endl;
156 check(P2.length() == 0);
158 cout << "P2.from()==v3 ? " << (P2.from()==v3) << endl;
159 check(P2.from() == v3);
160 cout << "P2.to()==v3 ? " << (P2.to()==v3) << endl;
161 check(P2.to() == v3);
164 cout << "Forditott ut letrehozasa: [6. pont, 1. pont]..."
166 LPath P2(P, P.nth<NodeIt>(5), P.nth<NodeIt>(0));
168 cout << "P2.length() == " << P2.length() << endl;
169 check(P2.length() == 5);
171 cout << "P2.from()==t ? " << (P2.from()==t) << endl;
172 check(P2.from() == t);
173 cout << "P2.to()==s ? " << (P2.to()==s) << endl;
178 cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
181 return passed ? 0 : 1;