src/test/graph_test.cc
author marci
Tue, 21 Sep 2004 11:54:20 +0000
changeset 892 004636791dd7
parent 873 f3a30fda2e49
child 906 17f31d280385
permissions -rw-r--r--
graph_wrappers now pass the tests.
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@880
    54
//Compile Graph
alpar@880
    55
template void hugo::checkCompileStaticGraph<skeleton::StaticGraph>
alpar@880
    56
(skeleton::StaticGraph &);
alpar@793
    57
alpar@880
    58
template void hugo::checkCompileGraph<skeleton::ExtendableGraph>
alpar@880
    59
(skeleton::ExtendableGraph &);
alpar@793
    60
alpar@880
    61
template void hugo::checkCompileErasableGraph<skeleton::ErasableGraph>
alpar@880
    62
(skeleton::ErasableGraph &);
alpar@733
    63
alpar@774
    64
//Compile SmartGraph
alpar@873
    65
template void hugo::checkCompileGraph<SmartGraph>(SmartGraph &);
alpar@873
    66
template void hugo::checkCompileGraphFindEdge<SmartGraph>(SmartGraph &);
deba@783
    67
alpar@774
    68
//Compile SymSmartGraph
alpar@873
    69
template void hugo::checkCompileGraph<SymSmartGraph>(SymSmartGraph &);
alpar@873
    70
template void hugo::checkCompileGraphFindEdge<SymSmartGraph>(SymSmartGraph &);
alpar@774
    71
alpar@774
    72
//Compile ListGraph
alpar@873
    73
template void hugo::checkCompileGraph<ListGraph>(ListGraph &);
alpar@873
    74
template void hugo::checkCompileErasableGraph<ListGraph>(ListGraph &);
alpar@873
    75
template void hugo::checkCompileGraphFindEdge<ListGraph>(ListGraph &);
alpar@774
    76
deba@783
    77
alpar@774
    78
//Compile SymListGraph
alpar@873
    79
template void hugo::checkCompileGraph<SymListGraph>(SymListGraph &);
alpar@873
    80
template void hugo::checkCompileErasableGraph<SymListGraph>(SymListGraph &);
alpar@873
    81
template void hugo::checkCompileGraphFindEdge<SymListGraph>(SymListGraph &);
alpar@774
    82
alpar@774
    83
//Compile FullGraph
alpar@873
    84
template void hugo::checkCompileStaticGraph<FullGraph>(FullGraph &);
alpar@873
    85
template void hugo::checkCompileGraphFindEdge<FullGraph>(FullGraph &);
alpar@550
    86
alpar@774
    87
//Compile EdgeSet <ListGraph>
alpar@873
    88
template void hugo::checkCompileGraph<EdgeSet <ListGraph> >
alpar@800
    89
(EdgeSet <ListGraph> &);
alpar@873
    90
template void hugo::checkCompileGraphEraseEdge<EdgeSet <ListGraph> >
alpar@873
    91
(EdgeSet <ListGraph> &);
alpar@873
    92
template void hugo::checkCompileGraphFindEdge<EdgeSet <ListGraph> >
alpar@800
    93
(EdgeSet <ListGraph> &);
alpar@774
    94
alpar@774
    95
//Compile EdgeSet <NodeSet>
alpar@873
    96
template void hugo::checkCompileGraph<EdgeSet <NodeSet> >(EdgeSet <NodeSet> &);
alpar@873
    97
template void hugo::checkCompileGraphEraseEdge<EdgeSet <NodeSet> >
alpar@800
    98
(EdgeSet <NodeSet> &);
alpar@873
    99
template void hugo::checkCompileGraphFindEdge<EdgeSet <NodeSet> >
alpar@800
   100
(EdgeSet <NodeSet> &);
alpar@774
   101
alpar@503
   102
alpar@503
   103
int main() 
alpar@503
   104
{
alpar@503
   105
  {
alpar@503
   106
    SmartGraph G;
alpar@503
   107
    addPetersen(G);
alpar@503
   108
    bidirPetersen(G);
alpar@503
   109
    checkPetersen(G);
alpar@503
   110
  }
alpar@578
   111
  {
alpar@578
   112
    ListGraph G;
alpar@578
   113
    addPetersen(G);
alpar@578
   114
    bidirPetersen(G);
alpar@578
   115
    checkPetersen(G);
alpar@578
   116
  }
alpar@503
   117
  {
alpar@503
   118
    SymSmartGraph G;
alpar@503
   119
    addPetersen(G);
alpar@503
   120
    checkPetersen(G);
alpar@503
   121
  }
alpar@578
   122
  {
alpar@578
   123
    SymListGraph G;
alpar@578
   124
    addPetersen(G);
alpar@578
   125
    checkPetersen(G);
alpar@578
   126
  }
alpar@503
   127
alpar@774
   128
  ///\file
alpar@774
   129
  ///\todo map tests.
alpar@774
   130
  ///\todo copy constr tests.
alpar@503
   131
alpar@503
   132
  std::cout << __FILE__ ": All tests passed.\n";
alpar@503
   133
alpar@579
   134
  return 0;
alpar@503
   135
}