COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/test/graph_test.cc @ 942:75fdd0c6866d

Last change on this file since 942:75fdd0c6866d was 938:70e2886211d5, checked in by Alpar Juttner, 20 years ago

Many of ckeckCompileXYZ()'s are now in the corresponding skeleton headers.
(Tests for Symmetric Graphs are still to be moved)

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