Changeset 228:b6732e0d38c5 in lemon for test/dfs_test.cc
 Timestamp:
 07/21/08 16:30:28 (16 years ago)
 Branch:
 default
 Children:
 229:aebc0161f6e5, 230:af4e8ba94294
 Phase:
 public
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

test/dfs_test.cc
r209 r228 20 20 #include <lemon/smart_graph.h> 21 21 #include <lemon/list_graph.h> 22 #include <lemon/lgf_reader.h> 23 22 24 #include <lemon/dfs.h> 23 25 #include <lemon/path.h> … … 27 29 28 30 using namespace lemon; 31 32 char test_lgf[] = 33 "@nodes\n" 34 "label\n" 35 "0\n" 36 "1\n" 37 "2\n" 38 "3\n" 39 "4\n" 40 "5\n" 41 "6\n" 42 "@arcs\n" 43 " label\n" 44 "0 1 0\n" 45 "1 2 1\n" 46 "2 3 2\n" 47 "1 4 3\n" 48 "4 2 4\n" 49 "4 5 5\n" 50 "5 0 6\n" 51 "6 3 7\n" 52 "@attributes\n" 53 "source 0\n" 54 "target 5\n"; 29 55 30 56 void checkDfsCompile() … … 40 66 DType::DistMap d(G); 41 67 DType::PredMap p(G); 42 // DType::PredNodeMap pn(G);43 68 44 69 DType dfs_test(G); … … 51 76 d = dfs_test.distMap(); 52 77 p = dfs_test.predMap(); 53 // pn = dfs_test.predNodeMap();54 78 b = dfs_test.reached(n); 55 79 … … 81 105 Digraph G; 82 106 Node s, t; 83 PetStruct<Digraph> ps = addPetersen(G, 5);84 107 85 s=ps.outer[2]; 86 t=ps.inner[0]; 108 std::istringstream input(test_lgf); 109 digraphReader(input, G). 110 node("source", s). 111 node("target", t). 112 run(); 87 113 88 114 Dfs<Digraph> dfs_test(G); … … 96 122 97 123 for(NodeIt v(G); v!=INVALID; ++v) { 98 check(dfs_test.reached(v),"Each node should be reached."); 99 if ( dfs_test.predArc(v)!=INVALID ) { 100 Arc e=dfs_test.predArc(v); 101 Node u=G.source(e); 102 check(u==dfs_test.predNode(v),"Wrong tree."); 103 check(dfs_test.dist(v)  dfs_test.dist(u) == 1, 104 "Wrong distance. (" << dfs_test.dist(u) << ">" 105 <<dfs_test.dist(v) << ')'); 124 if (dfs_test.reached(v)) { 125 check(v==s  dfs_test.predArc(v)!=INVALID, "Wrong tree."); 126 if (dfs_test.predArc(v)!=INVALID ) { 127 Arc e=dfs_test.predArc(v); 128 Node u=G.source(e); 129 check(u==dfs_test.predNode(v),"Wrong tree."); 130 check(dfs_test.dist(v)  dfs_test.dist(u) == 1, 131 "Wrong distance. (" << dfs_test.dist(u) << ">" 132 <<dfs_test.dist(v) << ')'); 133 } 106 134 } 107 135 }
Note: See TracChangeset
for help on using the changeset viewer.