COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/test/graph_test.cc @ 919:6153d9cf78c6

Last change on this file since 919:6153d9cf78c6 was 919:6153d9cf78c6, checked in by Alpar Juttner, 17 years ago
  • Backport -r1227 and -r1220
  • Temporarily remove (move to attic) tight_edge_filter.h
File size: 3.9 KB
Line 
1/* -*- C++ -*-
2 * src/test/graph_test.cc - Part of HUGOlib, a generic C++ optimization library
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
17#include<iostream>
18#include<hugo/smart_graph.h>
19#include<hugo/skeletons/graph.h>
20#include<hugo/list_graph.h>
21#include<hugo/full_graph.h>
22
23#include"test_tools.h"
24#include"graph_test.h"
25
26/**
27\file
28This test makes consistency checks of list graph structures.
29
30G.addNode(), G.addEdge(), G.tail(), G.head()
31
32\todo Checks for empty graphs and isolated points.
33conversion.
34*/
35
36using namespace hugo;
37
38template<class Graph> void bidirPetersen(Graph &G)
39{
40  typedef typename Graph::Edge Edge;
41  typedef typename Graph::EdgeIt EdgeIt;
42 
43  checkGraphEdgeList(G,15);
44 
45  std::vector<Edge> ee;
46 
47  for(EdgeIt e(G);e!=INVALID;++e) ee.push_back(e);
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
60  checkGraphNodeList(G,10);
61  checkGraphEdgeList(G,30);
62
63  for(NodeIt n(G);n!=INVALID;++n) {
64    checkGraphInEdgeList(G,n,3);
65    checkGraphOutEdgeList(G,n,3);
66    ++n;
67  } 
68}
69
70//Compile Graph
71template void hugo::checkCompileStaticGraph<skeleton::StaticGraph>
72(skeleton::StaticGraph &);
73
74template void hugo::checkCompileGraph<skeleton::ExtendableGraph>
75(skeleton::ExtendableGraph &);
76
77template void hugo::checkCompileErasableGraph<skeleton::ErasableGraph>
78(skeleton::ErasableGraph &);
79
80//Compile SmartGraph
81template void hugo::checkCompileGraph<SmartGraph>(SmartGraph &);
82template void hugo::checkCompileGraphFindEdge<SmartGraph>(SmartGraph &);
83
84//Compile SymSmartGraph
85template void hugo::checkCompileGraph<SymSmartGraph>(SymSmartGraph &);
86template void hugo::checkCompileGraphFindEdge<SymSmartGraph>(SymSmartGraph &);
87
88//Compile ListGraph
89template void hugo::checkCompileGraph<ListGraph>(ListGraph &);
90template void hugo::checkCompileErasableGraph<ListGraph>(ListGraph &);
91template void hugo::checkCompileGraphFindEdge<ListGraph>(ListGraph &);
92
93
94//Compile SymListGraph
95template void hugo::checkCompileGraph<SymListGraph>(SymListGraph &);
96template void hugo::checkCompileErasableGraph<SymListGraph>(SymListGraph &);
97template void hugo::checkCompileGraphFindEdge<SymListGraph>(SymListGraph &);
98
99//Compile FullGraph
100template void hugo::checkCompileStaticGraph<FullGraph>(FullGraph &);
101template void hugo::checkCompileGraphFindEdge<FullGraph>(FullGraph &);
102
103//Compile EdgeSet <ListGraph>
104template void hugo::checkCompileGraph<EdgeSet <ListGraph> >
105(EdgeSet <ListGraph> &);
106template void hugo::checkCompileGraphEraseEdge<EdgeSet <ListGraph> >
107(EdgeSet <ListGraph> &);
108template void hugo::checkCompileGraphFindEdge<EdgeSet <ListGraph> >
109(EdgeSet <ListGraph> &);
110
111//Compile EdgeSet <NodeSet>
112template void hugo::checkCompileGraph<EdgeSet <NodeSet> >(EdgeSet <NodeSet> &);
113template void hugo::checkCompileGraphEraseEdge<EdgeSet <NodeSet> >
114(EdgeSet <NodeSet> &);
115template void hugo::checkCompileGraphFindEdge<EdgeSet <NodeSet> >
116(EdgeSet <NodeSet> &);
117
118
119int main()
120{
121  {
122    SmartGraph G;
123    addPetersen(G);
124    bidirPetersen(G);
125    checkPetersen(G);
126  }
127  {
128    ListGraph G;
129    addPetersen(G);
130    bidirPetersen(G);
131    checkPetersen(G);
132  }
133  {
134    SymSmartGraph G;
135    addPetersen(G);
136    checkPetersen(G);
137  }
138  {
139    SymListGraph G;
140    addPetersen(G);
141    checkPetersen(G);
142  }
143
144  ///\file
145  ///\todo map tests.
146  ///\todo copy constr tests.
147
148  std::cout << __FILE__ ": All tests passed.\n";
149
150  return 0;
151}
Note: See TracBrowser for help on using the repository browser.