Changeset 346:ada5f74d1c9e in lemon
 Timestamp:
 09/02/08 22:32:04 (13 years ago)
 Branch:
 default
 Phase:
 public
 Files:

 1 added
 2 edited
Legend:
 Unmodified
 Added
 Removed

lemon/Makefile.am
r220 r346 31 31 lemon/error.h \ 32 32 lemon/graph_to_eps.h \ 33 lemon/grid_graph.h \ 33 34 lemon/kruskal.h \ 34 35 lemon/lgf_reader.h \ 
test/graph_test.cc
r228 r346 21 21 #include <lemon/smart_graph.h> 22 22 // #include <lemon/full_graph.h> 23 //#include <lemon/grid_graph.h>23 #include <lemon/grid_graph.h> 24 24 25 25 #include "test_tools.h" … … 127 127 // { // Checking FullGraph 128 128 // checkConcept<Graph, FullGraph>(); 129 // checkGraphIterators<FullGraph>();130 129 // } 131 // { // Checking GridGraph 132 // checkConcept<Graph, GridGraph>(); 133 // checkGraphIterators<GridGraph>(); 134 // } 130 { // Checking GridGraph 131 checkConcept<Graph, GridGraph>(); 132 } 135 133 } 136 134 … … 189 187 } 190 188 191 // void checkGridGraph(const GridGraph& g, int w, int h) { 192 // check(g.width() == w, "Wrong width"); 193 // check(g.height() == h, "Wrong height"); 194 195 // for (int i = 0; i < w; ++i) { 196 // for (int j = 0; j < h; ++j) { 197 // check(g.col(g(i, j)) == i, "Wrong col"); 198 // check(g.row(g(i, j)) == j, "Wrong row"); 199 // } 200 // } 201 202 // for (int i = 0; i < w; ++i) { 203 // for (int j = 0; j < h  1; ++j) { 204 // check(g.source(g.down(g(i, j))) == g(i, j), "Wrong down"); 205 // check(g.target(g.down(g(i, j))) == g(i, j + 1), "Wrong down"); 206 // } 207 // check(g.down(g(i, h  1)) == INVALID, "Wrong down"); 208 // } 209 210 // for (int i = 0; i < w; ++i) { 211 // for (int j = 1; j < h; ++j) { 212 // check(g.source(g.up(g(i, j))) == g(i, j), "Wrong up"); 213 // check(g.target(g.up(g(i, j))) == g(i, j  1), "Wrong up"); 214 // } 215 // check(g.up(g(i, 0)) == INVALID, "Wrong up"); 216 // } 217 218 // for (int j = 0; j < h; ++j) { 219 // for (int i = 0; i < w  1; ++i) { 220 // check(g.source(g.right(g(i, j))) == g(i, j), "Wrong right"); 221 // check(g.target(g.right(g(i, j))) == g(i + 1, j), "Wrong right"); 222 // } 223 // check(g.right(g(w  1, j)) == INVALID, "Wrong right"); 224 // } 225 226 // for (int j = 0; j < h; ++j) { 227 // for (int i = 1; i < w; ++i) { 228 // check(g.source(g.left(g(i, j))) == g(i, j), "Wrong left"); 229 // check(g.target(g.left(g(i, j))) == g(i  1, j), "Wrong left"); 230 // } 231 // check(g.left(g(0, j)) == INVALID, "Wrong left"); 232 // } 233 // } 189 void checkGridGraph(const GridGraph& g, int w, int h) { 190 check(g.width() == w, "Wrong width"); 191 check(g.height() == h, "Wrong height"); 192 193 for (int i = 0; i < w; ++i) { 194 for (int j = 0; j < h; ++j) { 195 check(g.col(g(i, j)) == i, "Wrong col"); 196 check(g.row(g(i, j)) == j, "Wrong row"); 197 } 198 } 199 200 for (int i = 0; i < w; ++i) { 201 for (int j = 0; j < h  1; ++j) { 202 check(g.source(g.down(g(i, j))) == g(i, j), "Wrong down"); 203 check(g.target(g.down(g(i, j))) == g(i, j + 1), "Wrong down"); 204 } 205 check(g.down(g(i, h  1)) == INVALID, "Wrong down"); 206 } 207 208 for (int i = 0; i < w; ++i) { 209 for (int j = 1; j < h; ++j) { 210 check(g.source(g.up(g(i, j))) == g(i, j), "Wrong up"); 211 check(g.target(g.up(g(i, j))) == g(i, j  1), "Wrong up"); 212 } 213 check(g.up(g(i, 0)) == INVALID, "Wrong up"); 214 } 215 216 for (int j = 0; j < h; ++j) { 217 for (int i = 0; i < w  1; ++i) { 218 check(g.source(g.right(g(i, j))) == g(i, j), "Wrong right"); 219 check(g.target(g.right(g(i, j))) == g(i + 1, j), "Wrong right"); 220 } 221 check(g.right(g(w  1, j)) == INVALID, "Wrong right"); 222 } 223 224 for (int j = 0; j < h; ++j) { 225 for (int i = 1; i < w; ++i) { 226 check(g.source(g.left(g(i, j))) == g(i, j), "Wrong left"); 227 check(g.target(g.left(g(i, j))) == g(i  1, j), "Wrong left"); 228 } 229 check(g.left(g(0, j)) == INVALID, "Wrong left"); 230 } 231 232 checkGraphNodeList(g, w*h); 233 checkGraphArcList(g, 2*(2*w*hwh)); 234 checkGraphEdgeList(g, 2*w*hwh); 235 236 checkGraphOutArcList(g, g(0,0), 2); 237 checkGraphOutArcList(g, g(0,1), 3); 238 checkGraphOutArcList(g, g(w2,h2), 4); 239 240 checkGraphInArcList(g, g(0,0), 2); 241 checkGraphInArcList(g, g(0,1), 3); 242 checkGraphInArcList(g, g(w2,h2), 4); 243 244 checkGraphIncEdgeList(g, g(0,0), 2); 245 checkGraphIncEdgeList(g, g(0,1), 3); 246 checkGraphIncEdgeList(g, g(w2,h2), 4); 247 248 checkGraphConArcList(g, 2*(2*w*hwh)); 249 checkGraphConEdgeList(g, 2*w*hwh); 250 251 checkArcDirections(g); 252 253 checkNodeIds(g); 254 checkArcIds(g); 255 checkEdgeIds(g); 256 checkGraphNodeMap(g); 257 checkGraphArcMap(g); 258 checkGraphEdgeMap(g); 259 } 234 260 235 261 void checkGraphs() { … … 247 273 // checkGraphEdgeList(g, 10); 248 274 // } 249 // { // Checking GridGraph 250 // GridGraph g(5, 6); 251 // checkGraphNodeList(g, 30); 252 // checkGraphEdgeList(g, 49); 253 // checkGridGraph(g, 5, 6); 254 // } 275 { // Checking GridGraph 276 GridGraph g(5, 6); 277 checkGridGraph(g, 5, 6); 278 } 255 279 } 256 280
Note: See TracChangeset
for help on using the changeset viewer.