src/test/dijkstra_test.cc
changeset 574 7b0b12eb603b
parent 568 ed0a4de23923
child 578 159f1cbf8a45
equal deleted inserted replaced
0:0114c52773df 1:d8c64833ef99
     3 #include <hugo/dijkstra.h>
     3 #include <hugo/dijkstra.h>
     4 
     4 
     5 using namespace hugo;
     5 using namespace hugo;
     6 
     6 
     7 const int PET_SIZE =5;
     7 const int PET_SIZE =5;
       
     8 
       
     9 
       
    10 void check_Dijkstra_SmartGraph_BinHeap_Compile() 
       
    11 {
       
    12   typedef int VType;
       
    13   typedef SmartGraph Graph;
       
    14 
       
    15   typedef Graph::Edge Edge;
       
    16   typedef Graph::Node Node;
       
    17   typedef Graph::EdgeIt EdgeIt;
       
    18   typedef Graph::NodeIt NodeIt;
       
    19   typedef Graph::EdgeMap<VType> LengthMap;
       
    20  
       
    21   typedef Dijkstra<Graph, LengthMap> DType;
       
    22   
       
    23   Graph G;
       
    24   Node n;
       
    25   Edge e;
       
    26   VType l;
       
    27   bool b;
       
    28   DType::DistMap d(G);
       
    29   DType::PredMap p(G);
       
    30   DType::PredNodeMap pn(G);
       
    31   LengthMap cap(G);
       
    32 
       
    33   DType dijkstra_test(G,cap);
       
    34 
       
    35   dijkstra_test.run(n);
       
    36 
       
    37   l  = dijkstra_test.dist(n);
       
    38   e  = dijkstra_test.pred(n);
       
    39   n  = dijkstra_test.predNode(n);
       
    40   d  = dijkstra_test.distMap();
       
    41   p  = dijkstra_test.predMap();
       
    42   pn = dijkstra_test.predNodeMap();
       
    43   b  = dijkstra_test.reached(n);
       
    44 
       
    45 }
     8 
    46 
     9 int main()
    47 int main()
    10 {
    48 {
    11     
    49     
    12   typedef SmartGraph Graph;
    50   typedef SmartGraph Graph;
    18   typedef Graph::EdgeMap<int> LengthMap;
    56   typedef Graph::EdgeMap<int> LengthMap;
    19 
    57 
    20   Graph G;
    58   Graph G;
    21   Node s, t;
    59   Node s, t;
    22   LengthMap cap(G);
    60   LengthMap cap(G);
    23 
       
    24   PetStruct<Graph> ps = addPetersen(G,PET_SIZE);
    61   PetStruct<Graph> ps = addPetersen(G,PET_SIZE);
    25   
    62   
    26   for(int i=0;i<PET_SIZE;i++) {
    63   for(int i=0;i<PET_SIZE;i++) {
    27     cap[ps.outcir[i]]=4;
    64     cap[ps.outcir[i]]=4;
    28     cap[ps.incir[i]]=1;
    65     cap[ps.incir[i]]=1;
    36   dijkstra_test.run(s);
    73   dijkstra_test.run(s);
    37   
    74   
    38   check(dijkstra_test.dist(t)==13,"Dijkstra found a wrong path.");
    75   check(dijkstra_test.dist(t)==13,"Dijkstra found a wrong path.");
    39   
    76   
    40 }
    77 }
    41