Changeset 377:a12eef1f82b2 in lemon for test
 Timestamp:
 11/06/08 15:16:37 (15 years ago)
 Branch:
 default
 Phase:
 public
 Location:
 test
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

test/digraph_test.cc
r376 r377 21 21 #include <lemon/smart_graph.h> 22 22 #include <lemon/full_graph.h> 23 #include <lemon/hypercube_graph.h>24 23 25 24 #include "test_tools.h" … … 113 112 } 114 113 115 void checkHypercubeDigraph(int dim) {116 DIGRAPH_TYPEDEFS(HypercubeDigraph);117 118 HypercubeDigraph G(dim);119 checkGraphNodeList(G, 1 << dim);120 checkGraphArcList(G, (1 << dim) * dim);121 122 Node n = G.nodeFromId(dim);123 124 checkGraphOutArcList(G, n, dim);125 for (OutArcIt a(G, n); a != INVALID; ++a)126 check(G.source(a) == n &&127 G.id(G.target(a)) == G.id(n) ^ (1 << G.dimension(a)),128 "Wrong arc");129 130 checkGraphInArcList(G, n, dim);131 for (InArcIt a(G, n); a != INVALID; ++a)132 check(G.target(a) == n &&133 G.id(G.source(a)) == G.id(n) ^ (1 << G.dimension(a)),134 "Wrong arc");135 136 checkGraphConArcList(G, (1 << dim) * dim);137 138 checkNodeIds(G);139 checkArcIds(G);140 checkGraphNodeMap(G);141 checkGraphArcMap(G);142 }143 144 145 114 void checkConcepts() { 146 115 { // Checking digraph components … … 175 144 checkConcept<Digraph, FullDigraph>(); 176 145 } 177 { // Checking HypercubeDigraph178 checkConcept<Digraph, HypercubeDigraph>();179 }180 146 } 181 147 … … 242 208 checkFullDigraph(8); 243 209 } 244 { // Checking HypercubeDigraph245 checkHypercubeDigraph(1);246 checkHypercubeDigraph(2);247 checkHypercubeDigraph(3);248 checkHypercubeDigraph(4);249 }250 210 } 251 211 
test/graph_test.cc
r368 r377 22 22 #include <lemon/full_graph.h> 23 23 #include <lemon/grid_graph.h> 24 #include <lemon/hypercube_graph.h> 24 25 25 26 #include "test_tools.h" … … 105 106 106 107 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); 108 checkGraphOutArcList(G, n, num  1); 109 checkGraphInArcList(G, n, num  1); 110 checkGraphIncEdgeList(G, n, num  1); 110 111 } 111 112 … … 122 123 checkGraphEdgeMap(G); 123 124 124 125 125 126 for (int i = 0; i < G.nodeNum(); ++i) { 126 127 check(G.index(G(i)) == i, "Wrong index"); … … 178 179 checkConcept<Graph, GridGraph>(); 179 180 } 181 { // Checking HypercubeGraph 182 checkConcept<Graph, HypercubeGraph>(); 183 } 180 184 } 181 185 … … 313 317 } 314 318 319 void checkHypercubeGraph(int dim) { 320 GRAPH_TYPEDEFS(HypercubeGraph); 321 322 HypercubeGraph G(dim); 323 checkGraphNodeList(G, 1 << dim); 324 checkGraphEdgeList(G, dim * (1 << dim1)); 325 checkGraphArcList(G, dim * (1 << dim)); 326 327 Node n = G.nodeFromId(dim); 328 329 for (NodeIt n(G); n != INVALID; ++n) { 330 checkGraphIncEdgeList(G, n, dim); 331 for (IncEdgeIt e(G, n); e != INVALID; ++e) { 332 check( (G.u(e) == n && 333 G.id(G.v(e)) == G.id(n) ^ (1 << G.dimension(e)))  334 (G.v(e) == n && 335 G.id(G.u(e)) == G.id(n) ^ (1 << G.dimension(e))), 336 "Wrong edge or wrong dimension"); 337 } 338 339 checkGraphOutArcList(G, n, dim); 340 for (OutArcIt a(G, n); a != INVALID; ++a) { 341 check(G.source(a) == n && 342 G.id(G.target(a)) == G.id(n) ^ (1 << G.dimension(a)), 343 "Wrong arc or wrong dimension"); 344 } 345 346 checkGraphInArcList(G, n, dim); 347 for (InArcIt a(G, n); a != INVALID; ++a) { 348 check(G.target(a) == n && 349 G.id(G.source(a)) == G.id(n) ^ (1 << G.dimension(a)), 350 "Wrong arc or wrong dimension"); 351 } 352 } 353 354 checkGraphConArcList(G, (1 << dim) * dim); 355 checkGraphConEdgeList(G, dim * (1 << dim1)); 356 357 checkArcDirections(G); 358 359 checkNodeIds(G); 360 checkArcIds(G); 361 checkEdgeIds(G); 362 checkGraphNodeMap(G); 363 checkGraphArcMap(G); 364 checkGraphEdgeMap(G); 365 } 366 315 367 void checkGraphs() { 316 368 { // Checking ListGraph … … 322 374 checkGraphValidity<SmartGraph>(); 323 375 } 324 { // Checking FullGraph 376 { // Checking FullGraph 325 377 checkFullGraph(7); 326 378 checkFullGraph(8); … … 333 385 checkGridGraph(1, 1); 334 386 } 387 { // Checking HypercubeGraph 388 checkHypercubeGraph(1); 389 checkHypercubeGraph(2); 390 checkHypercubeGraph(3); 391 checkHypercubeGraph(4); 392 } 335 393 } 336 394
Note: See TracChangeset
for help on using the changeset viewer.