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