src/test/graph_test.cc
author marci
Fri, 01 Oct 2004 11:31:03 +0000
changeset 933 1b7c88fbb950
parent 919 6153d9cf78c6
child 937 d4e911acef3d
permissions -rw-r--r--
NodeSubGraphWrapper, test, and ducumentation modifications.
alpar@906
     1
/* -*- C++ -*-
alpar@921
     2
 * src/test/graph_test.cc - Part of LEMON, a generic C++ optimization library
alpar@906
     3
 *
alpar@906
     4
 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@906
     5
 * (Egervary Combinatorial Optimization Research Group, EGRES).
alpar@906
     6
 *
alpar@906
     7
 * Permission to use, modify and distribute this software is granted
alpar@906
     8
 * provided that this copyright notice appears in all copies. For
alpar@906
     9
 * precise terms see the accompanying LICENSE file.
alpar@906
    10
 *
alpar@906
    11
 * This software is provided "AS IS" with no warranty of any kind,
alpar@906
    12
 * express or implied, and with no claim as to its suitability for any
alpar@906
    13
 * purpose.
alpar@906
    14
 *
alpar@906
    15
 */
alpar@906
    16
alpar@503
    17
#include<iostream>
alpar@921
    18
#include<lemon/smart_graph.h>
alpar@921
    19
#include<lemon/skeletons/graph.h>
alpar@921
    20
#include<lemon/list_graph.h>
alpar@921
    21
#include<lemon/full_graph.h>
alpar@578
    22
alpar@567
    23
#include"test_tools.h"
alpar@800
    24
#include"graph_test.h"
alpar@567
    25
alpar@774
    26
/**
alpar@774
    27
\file
alpar@503
    28
This test makes consistency checks of list graph structures.
alpar@503
    29
alpar@774
    30
G.addNode(), G.addEdge(), G.tail(), G.head()
alpar@503
    31
alpar@592
    32
\todo Checks for empty graphs and isolated points.
alpar@774
    33
conversion.
alpar@503
    34
*/
alpar@503
    35
alpar@921
    36
using namespace lemon;
alpar@503
    37
alpar@503
    38
template<class Graph> void bidirPetersen(Graph &G)
alpar@503
    39
{
alpar@503
    40
  typedef typename Graph::Edge Edge;
alpar@503
    41
  typedef typename Graph::EdgeIt EdgeIt;
alpar@503
    42
  
alpar@800
    43
  checkGraphEdgeList(G,15);
alpar@503
    44
  
alpar@503
    45
  std::vector<Edge> ee;
alpar@503
    46
  
alpar@774
    47
  for(EdgeIt e(G);e!=INVALID;++e) ee.push_back(e);
alpar@503
    48
alpar@503
    49
  for(typename std::vector<Edge>::iterator p=ee.begin();p!=ee.end();p++)
alpar@503
    50
    G.addEdge(G.head(*p),G.tail(*p));
alpar@503
    51
}
alpar@503
    52
alpar@503
    53
template<class Graph> void checkPetersen(Graph &G)
alpar@503
    54
{
alpar@503
    55
  typedef typename Graph::Node Node;
alpar@503
    56
alpar@503
    57
  typedef typename Graph::EdgeIt EdgeIt;
alpar@503
    58
  typedef typename Graph::NodeIt NodeIt;
alpar@503
    59
alpar@800
    60
  checkGraphNodeList(G,10);
alpar@800
    61
  checkGraphEdgeList(G,30);
alpar@503
    62
alpar@774
    63
  for(NodeIt n(G);n!=INVALID;++n) {
alpar@800
    64
    checkGraphInEdgeList(G,n,3);
alpar@800
    65
    checkGraphOutEdgeList(G,n,3);
alpar@919
    66
    ++n;
alpar@503
    67
  }  
alpar@503
    68
}
alpar@503
    69
alpar@880
    70
//Compile Graph
alpar@921
    71
template void lemon::checkCompileStaticGraph<skeleton::StaticGraph>
alpar@880
    72
(skeleton::StaticGraph &);
alpar@793
    73
alpar@921
    74
template void lemon::checkCompileGraph<skeleton::ExtendableGraph>
alpar@880
    75
(skeleton::ExtendableGraph &);
alpar@793
    76
alpar@921
    77
template void lemon::checkCompileErasableGraph<skeleton::ErasableGraph>
alpar@880
    78
(skeleton::ErasableGraph &);
alpar@733
    79
alpar@774
    80
//Compile SmartGraph
alpar@921
    81
template void lemon::checkCompileGraph<SmartGraph>(SmartGraph &);
alpar@921
    82
template void lemon::checkCompileGraphFindEdge<SmartGraph>(SmartGraph &);
deba@783
    83
alpar@774
    84
//Compile SymSmartGraph
alpar@921
    85
template void lemon::checkCompileGraph<SymSmartGraph>(SymSmartGraph &);
alpar@921
    86
template void lemon::checkCompileGraphFindEdge<SymSmartGraph>(SymSmartGraph &);
alpar@774
    87
alpar@774
    88
//Compile ListGraph
alpar@921
    89
template void lemon::checkCompileGraph<ListGraph>(ListGraph &);
alpar@921
    90
template void lemon::checkCompileErasableGraph<ListGraph>(ListGraph &);
alpar@921
    91
template void lemon::checkCompileGraphFindEdge<ListGraph>(ListGraph &);
alpar@774
    92
deba@783
    93
alpar@774
    94
//Compile SymListGraph
alpar@921
    95
template void lemon::checkCompileGraph<SymListGraph>(SymListGraph &);
alpar@921
    96
template void lemon::checkCompileErasableGraph<SymListGraph>(SymListGraph &);
alpar@921
    97
template void lemon::checkCompileGraphFindEdge<SymListGraph>(SymListGraph &);
alpar@774
    98
alpar@774
    99
//Compile FullGraph
alpar@921
   100
template void lemon::checkCompileStaticGraph<FullGraph>(FullGraph &);
alpar@921
   101
template void lemon::checkCompileGraphFindEdge<FullGraph>(FullGraph &);
alpar@550
   102
alpar@774
   103
//Compile EdgeSet <ListGraph>
alpar@921
   104
template void lemon::checkCompileGraph<EdgeSet <ListGraph> >
alpar@800
   105
(EdgeSet <ListGraph> &);
alpar@921
   106
template void lemon::checkCompileGraphEraseEdge<EdgeSet <ListGraph> >
alpar@873
   107
(EdgeSet <ListGraph> &);
alpar@921
   108
template void lemon::checkCompileGraphFindEdge<EdgeSet <ListGraph> >
alpar@800
   109
(EdgeSet <ListGraph> &);
alpar@774
   110
alpar@774
   111
//Compile EdgeSet <NodeSet>
alpar@921
   112
template void lemon::checkCompileGraph<EdgeSet <NodeSet> >(EdgeSet <NodeSet> &);
alpar@921
   113
template void lemon::checkCompileGraphEraseEdge<EdgeSet <NodeSet> >
alpar@800
   114
(EdgeSet <NodeSet> &);
alpar@921
   115
template void lemon::checkCompileGraphFindEdge<EdgeSet <NodeSet> >
alpar@800
   116
(EdgeSet <NodeSet> &);
alpar@774
   117
alpar@503
   118
alpar@503
   119
int main() 
alpar@503
   120
{
alpar@503
   121
  {
alpar@503
   122
    SmartGraph G;
alpar@503
   123
    addPetersen(G);
alpar@503
   124
    bidirPetersen(G);
alpar@503
   125
    checkPetersen(G);
alpar@503
   126
  }
alpar@578
   127
  {
alpar@578
   128
    ListGraph G;
alpar@578
   129
    addPetersen(G);
alpar@578
   130
    bidirPetersen(G);
alpar@578
   131
    checkPetersen(G);
alpar@578
   132
  }
alpar@503
   133
  {
alpar@919
   134
    SymSmartGraph G;
alpar@919
   135
    addPetersen(G);
alpar@919
   136
    checkPetersen(G);
alpar@503
   137
  }
alpar@578
   138
  {
alpar@919
   139
    SymListGraph G;
alpar@919
   140
    addPetersen(G);
alpar@919
   141
    checkPetersen(G);
alpar@578
   142
  }
alpar@503
   143
alpar@774
   144
  ///\file
alpar@774
   145
  ///\todo map tests.
alpar@774
   146
  ///\todo copy constr tests.
alpar@503
   147
alpar@503
   148
  std::cout << __FILE__ ": All tests passed.\n";
alpar@503
   149
alpar@579
   150
  return 0;
alpar@503
   151
}