Changeset 518:fcdb561b8c78 in lemon-0.x for src/test/minlengthpaths_test.cc
- Timestamp:
- 05/04/04 11:00:11 (21 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@682
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
src/test/minlengthpaths_test.cc
r517 r518 1 #include <xy.h>2 1 #include <iostream> 2 #include <list_graph.h> 3 #include <minlengthpaths.h> 3 4 using namespace std; 4 5 using namespace hugo; 6 7 8 9 int main() 10 { 11 12 5 13 6 14 bool passed = true; … … 20 28 { 21 29 30 typedef ListGraph::Node Node; 31 typedef ListGraph::Edge Edge; 22 32 33 ListGraph graph; 23 34 24 typedef xy<int> XY; 25 26 XY seged; 27 XY a(1,2); 28 XY b(3,4); 35 //Ahuja könyv példája 29 36 30 seged = a+b; 31 check(seged.x==4 && seged.y==6); 37 Node s=graph.addNode(); 38 Node v2=graph.addNode(); 39 Node v3=graph.addNode(); 40 Node v4=graph.addNode(); 41 Node v5=graph.addNode(); 42 Node t=graph.addNode(); 32 43 33 seged = a-b; 34 check(seged.x==-2 && seged.y==-2, "a-b"); 44 Edge s_v2=graph.addEdge(s, v2); 45 Edge s_v3=graph.addEdge(s, v3); 46 Edge v2_v4=graph.addEdge(v2, v4); 47 Edge v2_v5=graph.addEdge(v2, v5); 48 Edge v3_v5=graph.addEdge(v3, v5); 49 Edge v4_t=graph.addEdge(v4, t); 50 Edge v5_t=graph.addEdge(v5, t); 51 35 52 36 check(a.normSquare()==5); 37 check(a*b==11, "a*b"); 53 ListGraph::EdgeMap<int> length(graph); 38 54 39 int l=2; 40 seged = a*l; 41 check(seged.x==2 && seged.y==4, "a*l"); 55 length.set(s_v2, 10); 56 length.set(s_v3, 10); 57 length.set(v2_v4, 5); 58 length.set(v2_v5, 1); 59 length.set(v3_v5, 5); 60 length.set(v4_t, 8); 61 length.set(v5_t, 8); 42 62 43 seged = b/l; 44 check(seged.x==1 && seged.y==2, "b/l"); 63 std::cout << "Minlengthpaths algorithm test..." << std::endl; 45 64 46 typedef BoundingBox<int> BB; 47 BB doboz1; 48 check(doboz1.empty(), "empty? Should be."); 49 50 doboz1 += a; 51 check(!doboz1.empty(), "empty? Should not be."); 52 doboz1 += b; 65 66 int k=3; 67 MinLengthPaths<ListGraph, ListGraph::EdgeMap<int> > 68 surb_test(graph, length); 53 69 54 check(doboz1.bottomLeft().x==1 && 55 doboz1.bottomLeft().y==2 && 56 doboz1.topRight().x==3 && 57 doboz1.topRight().y==4, 58 "added points to box"); 70 check( surb_test.run(s,t,k) == 2 && suurb_test.totalLength == 46,"Two paths, total length should be 46"); 59 71 60 seged.x=2;seged.y=3;61 check(doboz1.inside(seged),"Inside? Should be.");72 k=1; 73 check( surb_test.run(s,t,k) == 1 && suurb_test.totalLength == 19,"One path, total length should be 19"); 62 74 63 seged.x=1;seged.y=3; 64 check(doboz1.inside(seged),"Inside? Should be.");75 cout << (passed ? "All tests passed." : "Some of the tests failed!!!") 76 << endl; 65 77 66 seged.x=0;seged.y=3; 67 check(!doboz1.inside(seged),"Inside? Should not be."); 68 69 BB doboz2(seged); 70 check(!doboz2.empty(), "empty? Should not be. Constructed from 1 point."); 71 72 doboz2 += doboz1; 73 check(doboz2.inside(seged),"Inside? Should be. Incremented a box with an other."); 74 75 cout << (passed ? "All tests passed." : "Some of the tests failed!!!") 76 << endl; 77 78 return passed ? 0 : 1; 78 return passed ? 0 : 1; 79 79 80 80 }
Note: See TracChangeset
for help on using the changeset viewer.