319 void checkHypercubeGraph(int dim) { |
319 void checkHypercubeGraph(int dim) { |
320 GRAPH_TYPEDEFS(HypercubeGraph); |
320 GRAPH_TYPEDEFS(HypercubeGraph); |
321 |
321 |
322 HypercubeGraph G(dim); |
322 HypercubeGraph G(dim); |
323 checkGraphNodeList(G, 1 << dim); |
323 checkGraphNodeList(G, 1 << dim); |
324 checkGraphEdgeList(G, dim * (1 << dim-1)); |
324 checkGraphEdgeList(G, dim * (1 << (dim-1))); |
325 checkGraphArcList(G, dim * (1 << dim)); |
325 checkGraphArcList(G, dim * (1 << dim)); |
326 |
326 |
327 Node n = G.nodeFromId(dim); |
327 Node n = G.nodeFromId(dim); |
328 |
328 |
329 for (NodeIt n(G); n != INVALID; ++n) { |
329 for (NodeIt n(G); n != INVALID; ++n) { |
330 checkGraphIncEdgeList(G, n, dim); |
330 checkGraphIncEdgeList(G, n, dim); |
331 for (IncEdgeIt e(G, n); e != INVALID; ++e) { |
331 for (IncEdgeIt e(G, n); e != INVALID; ++e) { |
332 check( (G.u(e) == n && |
332 check( (G.u(e) == n && |
333 G.id(G.v(e)) == G.id(n) ^ (1 << G.dimension(e))) || |
333 G.id(G.v(e)) == (G.id(n) ^ (1 << G.dimension(e)))) || |
334 (G.v(e) == n && |
334 (G.v(e) == n && |
335 G.id(G.u(e)) == G.id(n) ^ (1 << G.dimension(e))), |
335 G.id(G.u(e)) == (G.id(n) ^ (1 << G.dimension(e)))), |
336 "Wrong edge or wrong dimension"); |
336 "Wrong edge or wrong dimension"); |
337 } |
337 } |
338 |
338 |
339 checkGraphOutArcList(G, n, dim); |
339 checkGraphOutArcList(G, n, dim); |
340 for (OutArcIt a(G, n); a != INVALID; ++a) { |
340 for (OutArcIt a(G, n); a != INVALID; ++a) { |
341 check(G.source(a) == n && |
341 check(G.source(a) == n && |
342 G.id(G.target(a)) == G.id(n) ^ (1 << G.dimension(a)), |
342 G.id(G.target(a)) == (G.id(n) ^ (1 << G.dimension(a))), |
343 "Wrong arc or wrong dimension"); |
343 "Wrong arc or wrong dimension"); |
344 } |
344 } |
345 |
345 |
346 checkGraphInArcList(G, n, dim); |
346 checkGraphInArcList(G, n, dim); |
347 for (InArcIt a(G, n); a != INVALID; ++a) { |
347 for (InArcIt a(G, n); a != INVALID; ++a) { |
348 check(G.target(a) == n && |
348 check(G.target(a) == n && |
349 G.id(G.source(a)) == G.id(n) ^ (1 << G.dimension(a)), |
349 G.id(G.source(a)) == (G.id(n) ^ (1 << G.dimension(a))), |
350 "Wrong arc or wrong dimension"); |
350 "Wrong arc or wrong dimension"); |
351 } |
351 } |
352 } |
352 } |
353 |
353 |
354 checkGraphConArcList(G, (1 << dim) * dim); |
354 checkGraphConArcList(G, (1 << dim) * dim); |
355 checkGraphConEdgeList(G, dim * (1 << dim-1)); |
355 checkGraphConEdgeList(G, dim * (1 << (dim-1))); |
356 |
356 |
357 checkArcDirections(G); |
357 checkArcDirections(G); |
358 |
358 |
359 checkNodeIds(G); |
359 checkNodeIds(G); |
360 checkArcIds(G); |
360 checkArcIds(G); |