COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/test/graph_test.cc @ 937:d4e911acef3d

Last change on this file since 937:d4e911acef3d was 937:d4e911acef3d, checked in by Balazs Dezso, 20 years ago

Revert backport changes -r1230.

File size: 4.0 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
[921]70template void lemon::checkCompileStaticGraph<skeleton::StaticGraph>
[880]71(skeleton::StaticGraph &);
[793]72
[921]73template void lemon::checkCompileGraph<skeleton::ExtendableGraph>
[880]74(skeleton::ExtendableGraph &);
[793]75
[921]76template void lemon::checkCompileErasableGraph<skeleton::ErasableGraph>
[880]77(skeleton::ErasableGraph &);
[733]78
[774]79//Compile SmartGraph
[921]80template void lemon::checkCompileGraph<SmartGraph>(SmartGraph &);
81template void lemon::checkCompileGraphFindEdge<SmartGraph>(SmartGraph &);
[783]82
[774]83//Compile SymSmartGraph
[937]84//template void hugo::checkCompileGraph<SymSmartGraph>(SymSmartGraph &);
85//template void hugo::checkCompileGraphFindEdge<SymSmartGraph>(SymSmartGraph &);
[774]86
87//Compile ListGraph
[921]88template void lemon::checkCompileGraph<ListGraph>(ListGraph &);
89template void lemon::checkCompileErasableGraph<ListGraph>(ListGraph &);
90template void lemon::checkCompileGraphFindEdge<ListGraph>(ListGraph &);
[774]91
[783]92
[774]93//Compile SymListGraph
[937]94//template void hugo::checkCompileGraph<SymListGraph>(SymListGraph &);
95//template void hugo::checkCompileErasableGraph<SymListGraph>(SymListGraph &);
96//template void hugo::checkCompileGraphFindEdge<SymListGraph>(SymListGraph &);
[774]97
98//Compile FullGraph
[921]99template void lemon::checkCompileStaticGraph<FullGraph>(FullGraph &);
100template void lemon::checkCompileGraphFindEdge<FullGraph>(FullGraph &);
[550]101
[774]102//Compile EdgeSet <ListGraph>
[921]103template void lemon::checkCompileGraph<EdgeSet <ListGraph> >
[800]104(EdgeSet <ListGraph> &);
[921]105template void lemon::checkCompileGraphEraseEdge<EdgeSet <ListGraph> >
[873]106(EdgeSet <ListGraph> &);
[921]107template void lemon::checkCompileGraphFindEdge<EdgeSet <ListGraph> >
[800]108(EdgeSet <ListGraph> &);
[774]109
110//Compile EdgeSet <NodeSet>
[921]111template void lemon::checkCompileGraph<EdgeSet <NodeSet> >(EdgeSet <NodeSet> &);
112template void lemon::checkCompileGraphEraseEdge<EdgeSet <NodeSet> >
[800]113(EdgeSet <NodeSet> &);
[921]114template void lemon::checkCompileGraphFindEdge<EdgeSet <NodeSet> >
[800]115(EdgeSet <NodeSet> &);
[774]116
[503]117
118int main()
119{
120  {
121    SmartGraph G;
122    addPetersen(G);
123    bidirPetersen(G);
124    checkPetersen(G);
125  }
[578]126  {
127    ListGraph G;
128    addPetersen(G);
129    bidirPetersen(G);
130    checkPetersen(G);
131  }
[503]132  {
[937]133    //    SymSmartGraph G;
134    //    addPetersen(G);
135    //    checkPetersen(G);
[503]136  }
[578]137  {
[937]138    //    SymListGraph G;
139    //    addPetersen(G);
140    //    checkPetersen(G);
[578]141  }
[503]142
[774]143  ///\file
144  ///\todo map tests.
145  ///\todo copy constr tests.
[503]146
147  std::cout << __FILE__ ": All tests passed.\n";
148
[579]149  return 0;
[503]150}
Note: See TracBrowser for help on using the repository browser.