COIN-OR::LEMON - Graph Library

Changeset 518:fcdb561b8c78 in lemon-0.x for src


Ignore:
Timestamp:
05/04/04 11:00:11 (20 years ago)
Author:
athos
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@682
Message:

Started minlengthpaths_test, but it should not be here

Location:
src/test
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • src/test/minlengthpaths_test.cc

    r517 r518  
    1 #include <xy.h>
    21#include <iostream>
     2#include <list_graph.h>
     3#include <minlengthpaths.h>
    34using namespace std;
    45using namespace hugo;
     6
     7
     8
     9int main()
     10{
     11
     12 
    513
    614bool passed = true;
     
    2028{
    2129
     30  typedef ListGraph::Node Node;
     31  typedef ListGraph::Edge Edge;
    2232
     33  ListGraph graph;
    2334
    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
    2936
    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();
    3243
    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 
    3552
    36         check(a.normSquare()==5);
    37         check(a*b==11, "a*b");
     53  ListGraph::EdgeMap<int> length(graph);
    3854
    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);
    4262
    43         seged = b/l;
    44         check(seged.x==1 && seged.y==2, "b/l");
     63  std::cout << "Minlengthpaths algorithm test..." << std::endl;
    4564
    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);
    5369
    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");
    5971
    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");
    6274
    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;
    6577
    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;
    7979
    8080}
  • src/test/xy_test.cc

    r517 r518  
    2020{
    2121
    22 
     22  cout << "Testing classes xy and boundingbox." << endl;
    2323
    2424        typedef xy<int> XY;
Note: See TracChangeset for help on using the changeset viewer.