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