17 */ |
17 */ |
18 |
18 |
19 #include <lemon/concepts/graph.h> |
19 #include <lemon/concepts/graph.h> |
20 #include <lemon/list_graph.h> |
20 #include <lemon/list_graph.h> |
21 #include <lemon/smart_graph.h> |
21 #include <lemon/smart_graph.h> |
22 // #include <lemon/full_graph.h> |
22 #include <lemon/full_graph.h> |
23 // #include <lemon/grid_graph.h> |
23 // #include <lemon/grid_graph.h> |
24 |
24 |
25 #include "test_tools.h" |
25 #include "test_tools.h" |
26 #include "graph_test.h" |
26 #include "graph_test.h" |
27 |
27 |
93 checkGraphNodeMap(G); |
93 checkGraphNodeMap(G); |
94 checkGraphArcMap(G); |
94 checkGraphArcMap(G); |
95 checkGraphEdgeMap(G); |
95 checkGraphEdgeMap(G); |
96 } |
96 } |
97 |
97 |
|
98 void checkFullGraph(int num) { |
|
99 typedef FullGraph Graph; |
|
100 GRAPH_TYPEDEFS(Graph); |
|
101 |
|
102 Graph G(num); |
|
103 checkGraphNodeList(G, num); |
|
104 checkGraphEdgeList(G, num * (num - 1) / 2); |
|
105 |
|
106 for (NodeIt n(G); n != INVALID; ++n) { |
|
107 checkGraphOutArcList(G, n, num - 1); |
|
108 checkGraphInArcList(G, n, num - 1); |
|
109 checkGraphIncEdgeList(G, n, num - 1); |
|
110 } |
|
111 |
|
112 checkGraphConArcList(G, num * (num - 1)); |
|
113 checkGraphConEdgeList(G, num * (num - 1) / 2); |
|
114 |
|
115 checkArcDirections(G); |
|
116 |
|
117 checkNodeIds(G); |
|
118 checkArcIds(G); |
|
119 checkEdgeIds(G); |
|
120 checkGraphNodeMap(G); |
|
121 checkGraphArcMap(G); |
|
122 checkGraphEdgeMap(G); |
|
123 |
|
124 |
|
125 for (int i = 0; i < G.nodeNum(); ++i) { |
|
126 check(G.index(G(i)) == i, "Wrong index"); |
|
127 } |
|
128 |
|
129 for (NodeIt u(G); u != INVALID; ++u) { |
|
130 for (NodeIt v(G); v != INVALID; ++v) { |
|
131 Edge e = G.edge(u, v); |
|
132 Arc a = G.arc(u, v); |
|
133 if (u == v) { |
|
134 check(e == INVALID, "Wrong edge lookup"); |
|
135 check(a == INVALID, "Wrong arc lookup"); |
|
136 } else { |
|
137 check((G.u(e) == u && G.v(e) == v) || |
|
138 (G.u(e) == v && G.v(e) == u), "Wrong edge lookup"); |
|
139 check(G.source(a) == u && G.target(a) == v, "Wrong arc lookup"); |
|
140 } |
|
141 } |
|
142 } |
|
143 } |
|
144 |
98 void checkConcepts() { |
145 void checkConcepts() { |
99 { // Checking graph components |
146 { // Checking graph components |
100 checkConcept<BaseGraphComponent, BaseGraphComponent >(); |
147 checkConcept<BaseGraphComponent, BaseGraphComponent >(); |
101 |
148 |
102 checkConcept<IDableGraphComponent<>, |
149 checkConcept<IDableGraphComponent<>, |
122 checkConcept<Graph, SmartGraph>(); |
169 checkConcept<Graph, SmartGraph>(); |
123 checkConcept<AlterableGraphComponent<>, SmartGraph>(); |
170 checkConcept<AlterableGraphComponent<>, SmartGraph>(); |
124 checkConcept<ExtendableGraphComponent<>, SmartGraph>(); |
171 checkConcept<ExtendableGraphComponent<>, SmartGraph>(); |
125 checkConcept<ClearableGraphComponent<>, SmartGraph>(); |
172 checkConcept<ClearableGraphComponent<>, SmartGraph>(); |
126 } |
173 } |
127 // { // Checking FullGraph |
174 { // Checking FullGraph |
128 // checkConcept<Graph, FullGraph>(); |
175 checkConcept<Graph, FullGraph>(); |
129 // checkGraphIterators<FullGraph>(); |
176 } |
130 // } |
177 // { // Checking GridGraph |
131 // { // Checking GridGraph |
178 // checkConcept<Graph, GridGraph>(); |
132 // checkConcept<Graph, GridGraph>(); |
179 // } |
133 // checkGraphIterators<GridGraph>(); |
|
134 // } |
|
135 } |
180 } |
136 |
181 |
137 template <typename Graph> |
182 template <typename Graph> |
138 void checkGraphValidity() { |
183 void checkGraphValidity() { |
139 TEMPLATE_GRAPH_TYPEDEFS(Graph); |
184 TEMPLATE_GRAPH_TYPEDEFS(Graph); |
239 } |
284 } |
240 { // Checking SmartGraph |
285 { // Checking SmartGraph |
241 checkGraph<SmartGraph>(); |
286 checkGraph<SmartGraph>(); |
242 checkGraphValidity<SmartGraph>(); |
287 checkGraphValidity<SmartGraph>(); |
243 } |
288 } |
244 // { // Checking FullGraph |
289 { // Checking FullGraph |
245 // FullGraph g(5); |
290 checkFullGraph(7); |
246 // checkGraphNodeList(g, 5); |
291 checkFullGraph(8); |
247 // checkGraphEdgeList(g, 10); |
292 } |
248 // } |
|
249 // { // Checking GridGraph |
293 // { // Checking GridGraph |
250 // GridGraph g(5, 6); |
294 // GridGraph g(5, 6); |
251 // checkGraphNodeList(g, 30); |
295 // checkGraphNodeList(g, 30); |
252 // checkGraphEdgeList(g, 49); |
296 // checkGraphEdgeList(g, 49); |
253 // checkGridGraph(g, 5, 6); |
297 // checkGridGraph(g, 5, 6); |