COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/test/graph_test.cc @ 808:9cabbdd73375

Last change on this file since 808:9cabbdd73375 was 800:b70a494b4912, checked in by Alpar Juttner, 20 years ago

Move general graph compilation tests to 'src/test/graph_test.h'.

File size: 3.3 KB
Line 
1#include<iostream>
2#include<hugo/smart_graph.h>
3#include<hugo/skeletons/graph.h>
4#include<hugo/list_graph.h>
5#include<hugo/full_graph.h>
6
7#include"test_tools.h"
8#include"graph_test.h"
9
10/**
11\file
12This test makes consistency checks of list graph structures.
13
14G.addNode(), G.addEdge(), G.tail(), G.head()
15
16\todo Checks for empty graphs and isolated points.
17conversion.
18*/
19
20using namespace hugo;
21
22template<class Graph> void bidirPetersen(Graph &G)
23{
24  typedef typename Graph::Edge Edge;
25  typedef typename Graph::EdgeIt EdgeIt;
26 
27  checkGraphEdgeList(G,15);
28 
29  std::vector<Edge> ee;
30 
31  for(EdgeIt e(G);e!=INVALID;++e) ee.push_back(e);
32
33  for(typename std::vector<Edge>::iterator p=ee.begin();p!=ee.end();p++)
34    G.addEdge(G.head(*p),G.tail(*p));
35}
36
37template<class Graph> void checkPetersen(Graph &G)
38{
39  typedef typename Graph::Node Node;
40
41  typedef typename Graph::EdgeIt EdgeIt;
42  typedef typename Graph::NodeIt NodeIt;
43
44  checkGraphNodeList(G,10);
45  checkGraphEdgeList(G,30);
46
47  for(NodeIt n(G);n!=INVALID;++n) {
48    checkGraphInEdgeList(G,n,3);
49    checkGraphOutEdgeList(G,n,3);
50    ++n;
51  } 
52}
53
54//Compile GraphSkeleton
55template void checkCompileStaticGraph<skeleton::StaticGraphSkeleton>
56(skeleton::StaticGraphSkeleton &);
57
58template void checkCompileGraph<skeleton::GraphSkeleton>
59(skeleton::GraphSkeleton &);
60
61template void checkCompileErasableGraph<skeleton::EraseableGraphSkeleton>
62(skeleton::EraseableGraphSkeleton &);
63
64//Compile SmartGraph
65template void checkCompileGraph<SmartGraph>(SmartGraph &);
66template void checkCompileGraphFindEdge<SmartGraph>(SmartGraph &);
67
68//Compile SymSmartGraph
69template void checkCompileGraph<SymSmartGraph>(SymSmartGraph &);
70template void checkCompileGraphFindEdge<SymSmartGraph>(SymSmartGraph &);
71
72//Compile ListGraph
73template void checkCompileGraph<ListGraph>(ListGraph &);
74template void checkCompileErasableGraph<ListGraph>(ListGraph &);
75template void checkCompileGraphFindEdge<ListGraph>(ListGraph &);
76
77
78//Compile SymListGraph
79template void checkCompileGraph<SymListGraph>(SymListGraph &);
80template void checkCompileErasableGraph<SymListGraph>(SymListGraph &);
81template void checkCompileGraphFindEdge<SymListGraph>(SymListGraph &);
82
83//Compile FullGraph
84template void checkCompileStaticGraph<FullGraph>(FullGraph &);
85template void checkCompileGraphFindEdge<FullGraph>(FullGraph &);
86
87//Compile EdgeSet <ListGraph>
88template void checkCompileGraph<EdgeSet <ListGraph> >(EdgeSet <ListGraph> &);
89template void checkCompileGraphEraseEdge<EdgeSet <ListGraph> >
90(EdgeSet <ListGraph> &);
91template void checkCompileGraphFindEdge<EdgeSet <ListGraph> >
92(EdgeSet <ListGraph> &);
93
94//Compile EdgeSet <NodeSet>
95template void checkCompileGraph<EdgeSet <NodeSet> >(EdgeSet <NodeSet> &);
96template void checkCompileGraphEraseEdge<EdgeSet <NodeSet> >
97(EdgeSet <NodeSet> &);
98template void checkCompileGraphFindEdge<EdgeSet <NodeSet> >
99(EdgeSet <NodeSet> &);
100
101
102int main()
103{
104  {
105    SmartGraph G;
106    addPetersen(G);
107    bidirPetersen(G);
108    checkPetersen(G);
109  }
110  {
111    ListGraph G;
112    addPetersen(G);
113    bidirPetersen(G);
114    checkPetersen(G);
115  }
116  {
117    SymSmartGraph G;
118    addPetersen(G);
119    checkPetersen(G);
120  }
121  {
122    SymListGraph G;
123    addPetersen(G);
124    checkPetersen(G);
125  }
126
127  ///\file
128  ///\todo map tests.
129  ///\todo copy constr tests.
130
131  std::cout << __FILE__ ": All tests passed.\n";
132
133  return 0;
134}
Note: See TracBrowser for help on using the repository browser.