src/test/bfs_test.cc
changeset 1160 d9c32f713cad
parent 959 c80ef5912903
child 1164 80bb73097736
equal deleted inserted replaced
6:3a711f722d2e 7:2dd7fcd7f2c3
    81   
    81   
    82   check(bfs_test.dist(t)==3,"Bfs found a wrong path. " << bfs_test.dist(t));
    82   check(bfs_test.dist(t)==3,"Bfs found a wrong path. " << bfs_test.dist(t));
    83 
    83 
    84 
    84 
    85   for(EdgeIt e(G); e==INVALID; ++e) {
    85   for(EdgeIt e(G); e==INVALID; ++e) {
    86     Node u=G.tail(e);
    86     Node u=G.source(e);
    87     Node v=G.head(e);
    87     Node v=G.target(e);
    88     check( !bfs_test.reached(u) ||
    88     check( !bfs_test.reached(u) ||
    89 	   (bfs_test.dist(v) > bfs_test.dist(u)+1),
    89 	   (bfs_test.dist(v) > bfs_test.dist(u)+1),
    90 	   "Wrong output.");
    90 	   "Wrong output.");
    91   }
    91   }
    92 
    92 
    93   for(NodeIt v(G); v==INVALID; ++v) {
    93   for(NodeIt v(G); v==INVALID; ++v) {
    94     check(bfs_test.reached(v),"Each node should be reached.");
    94     check(bfs_test.reached(v),"Each node should be reached.");
    95     if ( bfs_test.pred(v)!=INVALID ) {
    95     if ( bfs_test.pred(v)!=INVALID ) {
    96       Edge e=bfs_test.pred(v);
    96       Edge e=bfs_test.pred(v);
    97       Node u=G.tail(e);
    97       Node u=G.source(e);
    98       check(u==bfs_test.predNode(v),"Wrong tree.");
    98       check(u==bfs_test.predNode(v),"Wrong tree.");
    99       check(bfs_test.dist(v) - bfs_test.dist(u) == 1,
    99       check(bfs_test.dist(v) - bfs_test.dist(u) == 1,
   100 	    "Wrong distance. Difference: " 
   100 	    "Wrong distance. Difference: " 
   101 	    << std::abs(bfs_test.dist(v) - bfs_test.dist(u) 
   101 	    << std::abs(bfs_test.dist(v) - bfs_test.dist(u) 
   102 			- 1));
   102 			- 1));