src/test/graph_test.cc
author alpar
Thu, 16 Sep 2004 19:23:41 +0000
changeset 873 f3a30fda2e49
parent 826 056fbb112b30
child 880 9d0bfd35b97c
permissions -rw-r--r--
- GraphSkeleton renamed to ExtendableGraphSkeleton
- Use full explicit namespaces in some places in order to work with icc. (I don't know why they are necessary.)
     1 #include<iostream>
     2 #include<hugo/smart_graph.h>
     3 #include<hugo/skeletons/graph.h>
     4 #include<hugo/list_graph.h>
     5 #include<hugo/full_graph.h>
     6 
     7 #include"test_tools.h"
     8 #include"graph_test.h"
     9 
    10 /**
    11 \file
    12 This test makes consistency checks of list graph structures.
    13 
    14 G.addNode(), G.addEdge(), G.tail(), G.head()
    15 
    16 \todo Checks for empty graphs and isolated points.
    17 conversion.
    18 */
    19 
    20 using namespace hugo;
    21 
    22 template<class Graph> void bidirPetersen(Graph &G)
    23 {
    24   typedef typename Graph::Edge Edge;
    25   typedef typename Graph::EdgeIt EdgeIt;
    26   
    27   checkGraphEdgeList(G,15);
    28   
    29   std::vector<Edge> ee;
    30   
    31   for(EdgeIt e(G);e!=INVALID;++e) ee.push_back(e);
    32 
    33   for(typename std::vector<Edge>::iterator p=ee.begin();p!=ee.end();p++)
    34     G.addEdge(G.head(*p),G.tail(*p));
    35 }
    36 
    37 template<class Graph> void checkPetersen(Graph &G)
    38 {
    39   typedef typename Graph::Node Node;
    40 
    41   typedef typename Graph::EdgeIt EdgeIt;
    42   typedef typename Graph::NodeIt NodeIt;
    43 
    44   checkGraphNodeList(G,10);
    45   checkGraphEdgeList(G,30);
    46 
    47   for(NodeIt n(G);n!=INVALID;++n) {
    48     checkGraphInEdgeList(G,n,3);
    49     checkGraphOutEdgeList(G,n,3);
    50     ++n;
    51   }  
    52 }
    53 
    54 //Compile GraphSkeleton
    55 template void hugo::checkCompileStaticGraph<skeleton::StaticGraphSkeleton>
    56 (skeleton::StaticGraphSkeleton &);
    57 
    58 template void hugo::checkCompileGraph<skeleton::ExtendableGraphSkeleton>
    59 (skeleton::ExtendableGraphSkeleton &);
    60 
    61 template void hugo::checkCompileErasableGraph<skeleton::ErasableGraphSkeleton>
    62 (skeleton::ErasableGraphSkeleton &);
    63 
    64 //Compile SmartGraph
    65 template void hugo::checkCompileGraph<SmartGraph>(SmartGraph &);
    66 template void hugo::checkCompileGraphFindEdge<SmartGraph>(SmartGraph &);
    67 
    68 //Compile SymSmartGraph
    69 template void hugo::checkCompileGraph<SymSmartGraph>(SymSmartGraph &);
    70 template void hugo::checkCompileGraphFindEdge<SymSmartGraph>(SymSmartGraph &);
    71 
    72 //Compile ListGraph
    73 template void hugo::checkCompileGraph<ListGraph>(ListGraph &);
    74 template void hugo::checkCompileErasableGraph<ListGraph>(ListGraph &);
    75 template void hugo::checkCompileGraphFindEdge<ListGraph>(ListGraph &);
    76 
    77 
    78 //Compile SymListGraph
    79 template void hugo::checkCompileGraph<SymListGraph>(SymListGraph &);
    80 template void hugo::checkCompileErasableGraph<SymListGraph>(SymListGraph &);
    81 template void hugo::checkCompileGraphFindEdge<SymListGraph>(SymListGraph &);
    82 
    83 //Compile FullGraph
    84 template void hugo::checkCompileStaticGraph<FullGraph>(FullGraph &);
    85 template void hugo::checkCompileGraphFindEdge<FullGraph>(FullGraph &);
    86 
    87 //Compile EdgeSet <ListGraph>
    88 template void hugo::checkCompileGraph<EdgeSet <ListGraph> >
    89 (EdgeSet <ListGraph> &);
    90 template void hugo::checkCompileGraphEraseEdge<EdgeSet <ListGraph> >
    91 (EdgeSet <ListGraph> &);
    92 template void hugo::checkCompileGraphFindEdge<EdgeSet <ListGraph> >
    93 (EdgeSet <ListGraph> &);
    94 
    95 //Compile EdgeSet <NodeSet>
    96 template void hugo::checkCompileGraph<EdgeSet <NodeSet> >(EdgeSet <NodeSet> &);
    97 template void hugo::checkCompileGraphEraseEdge<EdgeSet <NodeSet> >
    98 (EdgeSet <NodeSet> &);
    99 template void hugo::checkCompileGraphFindEdge<EdgeSet <NodeSet> >
   100 (EdgeSet <NodeSet> &);
   101 
   102 
   103 int main() 
   104 {
   105   {
   106     SmartGraph G;
   107     addPetersen(G);
   108     bidirPetersen(G);
   109     checkPetersen(G);
   110   }
   111   {
   112     ListGraph G;
   113     addPetersen(G);
   114     bidirPetersen(G);
   115     checkPetersen(G);
   116   }
   117   {
   118     SymSmartGraph G;
   119     addPetersen(G);
   120     checkPetersen(G);
   121   }
   122   {
   123     SymListGraph G;
   124     addPetersen(G);
   125     checkPetersen(G);
   126   }
   127 
   128   ///\file
   129   ///\todo map tests.
   130   ///\todo copy constr tests.
   131 
   132   std::cout << __FILE__ ": All tests passed.\n";
   133 
   134   return 0;
   135 }