src/test/graph_factory_test.cc
author deba
Sat, 09 Apr 2005 19:30:49 +0000
changeset 1331 7e93d3f0406d
parent 986 e997802b855c
child 1359 1581f961cfaa
permissions -rw-r--r--
Documentation improvments.
klao@946
     1
/* -*- C++ -*-
klao@946
     2
 * src/test/graph_test.cc - Part of LEMON, a generic C++ optimization library
klao@946
     3
 *
alpar@1164
     4
 * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
klao@946
     5
 * (Egervary Combinatorial Optimization Research Group, EGRES).
klao@946
     6
 *
klao@946
     7
 * Permission to use, modify and distribute this software is granted
klao@946
     8
 * provided that this copyright notice appears in all copies. For
klao@946
     9
 * precise terms see the accompanying LICENSE file.
klao@946
    10
 *
klao@946
    11
 * This software is provided "AS IS" with no warranty of any kind,
klao@946
    12
 * express or implied, and with no claim as to its suitability for any
klao@946
    13
 * purpose.
klao@946
    14
 *
klao@946
    15
 */
klao@946
    16
klao@946
    17
#include<iostream>
klao@946
    18
#include<lemon/smart_graph.h>
klao@959
    19
#include<lemon/concept/graph.h>
klao@959
    20
#include<lemon/concept/maps.h>
klao@946
    21
#include<lemon/list_graph_base.h>
klao@946
    22
#include<lemon/full_graph.h>
klao@946
    23
klao@946
    24
#include"test_tools.h"
klao@946
    25
#include"graph_test.h"
klao@946
    26
klao@946
    27
/**
klao@946
    28
\file
klao@946
    29
This test makes consistency checks of list graph structures.
klao@946
    30
alpar@986
    31
G.addNode(), G.addEdge(), G.source(), G.target()
klao@946
    32
klao@946
    33
\todo Checks for empty graphs and isolated points.
klao@946
    34
conversion.
klao@946
    35
*/
klao@946
    36
klao@946
    37
using namespace lemon;
klao@946
    38
klao@946
    39
template<class Graph> void bidirPetersen(Graph &G)
klao@946
    40
{
klao@946
    41
  typedef typename Graph::Edge Edge;
klao@946
    42
  typedef typename Graph::EdgeIt EdgeIt;
klao@946
    43
  
klao@946
    44
  checkGraphEdgeList(G,15);
klao@946
    45
  
klao@946
    46
  std::vector<Edge> ee;
klao@946
    47
  
klao@946
    48
  for(EdgeIt e(G);e!=INVALID;++e) ee.push_back(e);
klao@946
    49
klao@946
    50
  for(typename std::vector<Edge>::iterator p=ee.begin();p!=ee.end();p++)
alpar@986
    51
    G.addEdge(G.target(*p),G.source(*p));
klao@946
    52
}
klao@946
    53
klao@946
    54
template<class Graph> void checkPetersen(Graph &G)
klao@946
    55
{
klao@946
    56
  typedef typename Graph::Node Node;
klao@946
    57
klao@946
    58
  typedef typename Graph::EdgeIt EdgeIt;
klao@946
    59
  typedef typename Graph::NodeIt NodeIt;
klao@946
    60
klao@946
    61
  checkGraphNodeList(G,10);
klao@946
    62
  checkGraphEdgeList(G,30);
klao@946
    63
klao@946
    64
  for(NodeIt n(G);n!=INVALID;++n) {
klao@946
    65
    checkGraphInEdgeList(G,n,3);
klao@946
    66
    checkGraphOutEdgeList(G,n,3);
klao@946
    67
  }  
klao@946
    68
}
klao@946
    69
klao@946
    70
//Compile Graph
klao@959
    71
template void lemon::concept::checkCompileStaticGraph<concept::StaticGraph>
klao@959
    72
(concept::StaticGraph &);
klao@946
    73
klao@946
    74
template
klao@959
    75
void lemon::concept::checkCompileExtendableGraph<concept::ExtendableGraph>
klao@959
    76
(concept::ExtendableGraph &);
klao@946
    77
klao@946
    78
template
klao@959
    79
void lemon::concept::checkCompileErasableGraph<concept::ErasableGraph>
klao@959
    80
(concept::ErasableGraph &);
klao@946
    81
klao@946
    82
//Compile SmartGraph
klao@946
    83
template
klao@959
    84
void lemon::concept::checkCompileExtendableGraph<SmartGraph>(SmartGraph &);
klao@946
    85
template
klao@959
    86
void lemon::concept::checkCompileGraphFindEdge<SmartGraph>(SmartGraph &);
klao@946
    87
klao@946
    88
//Compile SymSmartGraph
klao@946
    89
//template void hugo::checkCompileGraph<SymSmartGraph>(SymSmartGraph &);
klao@946
    90
//template void hugo::checkCompileGraphFindEdge<SymSmartGraph>(SymSmartGraph &);
klao@946
    91
klao@946
    92
//Compile ListGraph
klao@946
    93
template
klao@959
    94
void lemon::concept::checkCompileExtendableGraph<ListGraph>(ListGraph &);
klao@946
    95
template
klao@959
    96
void lemon::concept::checkCompileErasableGraph<ListGraph>(ListGraph &);
klao@946
    97
template
klao@959
    98
void lemon::concept::checkCompileGraphFindEdge<ListGraph>(ListGraph &);
klao@946
    99
klao@946
   100
klao@946
   101
//Compile SymListGraph
klao@946
   102
//template void hugo::checkCompileGraph<SymListGraph>(SymListGraph &);
klao@946
   103
//template void hugo::checkCompileErasableGraph<SymListGraph>(SymListGraph &);
klao@946
   104
//template void hugo::checkCompileGraphFindEdge<SymListGraph>(SymListGraph &);
klao@946
   105
klao@946
   106
//Compile FullGraph
klao@959
   107
template void lemon::concept::checkCompileStaticGraph<FullGraph>(FullGraph &);
klao@946
   108
template
klao@959
   109
void lemon::concept::checkCompileGraphFindEdge<FullGraph>(FullGraph &);
klao@946
   110
klao@946
   111
klao@946
   112
int main() 
klao@946
   113
{
klao@946
   114
  {
klao@946
   115
    SmartGraph G;
klao@946
   116
    addPetersen(G);
klao@946
   117
    bidirPetersen(G);
klao@946
   118
    checkPetersen(G);
klao@946
   119
  }
klao@946
   120
  {
klao@946
   121
    ListGraph G;
klao@946
   122
    addPetersen(G);
klao@946
   123
    bidirPetersen(G);
klao@946
   124
    checkPetersen(G);
klao@946
   125
  }
klao@946
   126
  {
klao@946
   127
    //    SymSmartGraph G;
klao@946
   128
    //    addPetersen(G);
klao@946
   129
    //    checkPetersen(G);
klao@946
   130
  }
klao@946
   131
  {
klao@946
   132
    //    SymListGraph G;
klao@946
   133
    //    addPetersen(G);
klao@946
   134
    //    checkPetersen(G);
klao@946
   135
  }
klao@946
   136
klao@946
   137
  ///\file
klao@946
   138
  ///\todo map tests.
klao@946
   139
  ///\todo copy constr tests.
klao@946
   140
klao@946
   141
klao@946
   142
  // Some map tests.
klao@946
   143
  // FIXME: These shouldn't be here.
klao@959
   144
  using namespace concept;
klao@946
   145
  function_requires< ReadMapConcept< ReadMap<int,int> > >();
klao@946
   146
  function_requires< WriteMapConcept< WriteMap<int,int> > >();
klao@946
   147
  function_requires< ReadWriteMapConcept< ReadWriteMap<int,int> > >();
klao@946
   148
  function_requires< ReferenceMapConcept< ReferenceMap<int,int> > >();
klao@946
   149
klao@946
   150
klao@946
   151
  std::cout << __FILE__ ": All tests passed.\n";
klao@946
   152
klao@946
   153
  return 0;
klao@946
   154
}