COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/test/graph_test.cc @ 879:5e284075b193

Last change on this file since 879:5e284075b193 was 873:f3a30fda2e49, checked in by Alpar Juttner, 20 years ago
File size: 3.4 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 hugo::checkCompileStaticGraph<skeleton::StaticGraphSkeleton>
56(skeleton::StaticGraphSkeleton &);
57
58template void hugo::checkCompileGraph<skeleton::ExtendableGraphSkeleton>
59(skeleton::ExtendableGraphSkeleton &);
60
61template void hugo::checkCompileErasableGraph<skeleton::ErasableGraphSkeleton>
62(skeleton::ErasableGraphSkeleton &);
63
64//Compile SmartGraph
65template void hugo::checkCompileGraph<SmartGraph>(SmartGraph &);
66template void hugo::checkCompileGraphFindEdge<SmartGraph>(SmartGraph &);
67
68//Compile SymSmartGraph
69template void hugo::checkCompileGraph<SymSmartGraph>(SymSmartGraph &);
70template void hugo::checkCompileGraphFindEdge<SymSmartGraph>(SymSmartGraph &);
71
72//Compile ListGraph
73template void hugo::checkCompileGraph<ListGraph>(ListGraph &);
74template void hugo::checkCompileErasableGraph<ListGraph>(ListGraph &);
75template void hugo::checkCompileGraphFindEdge<ListGraph>(ListGraph &);
76
77
78//Compile SymListGraph
79template void hugo::checkCompileGraph<SymListGraph>(SymListGraph &);
80template void hugo::checkCompileErasableGraph<SymListGraph>(SymListGraph &);
81template void hugo::checkCompileGraphFindEdge<SymListGraph>(SymListGraph &);
82
83//Compile FullGraph
84template void hugo::checkCompileStaticGraph<FullGraph>(FullGraph &);
85template void hugo::checkCompileGraphFindEdge<FullGraph>(FullGraph &);
86
87//Compile EdgeSet <ListGraph>
88template void hugo::checkCompileGraph<EdgeSet <ListGraph> >
89(EdgeSet <ListGraph> &);
90template void hugo::checkCompileGraphEraseEdge<EdgeSet <ListGraph> >
91(EdgeSet <ListGraph> &);
92template void hugo::checkCompileGraphFindEdge<EdgeSet <ListGraph> >
93(EdgeSet <ListGraph> &);
94
95//Compile EdgeSet <NodeSet>
96template void hugo::checkCompileGraph<EdgeSet <NodeSet> >(EdgeSet <NodeSet> &);
97template void hugo::checkCompileGraphEraseEdge<EdgeSet <NodeSet> >
98(EdgeSet <NodeSet> &);
99template void hugo::checkCompileGraphFindEdge<EdgeSet <NodeSet> >
100(EdgeSet <NodeSet> &);
101
102
103int main()
104{
105  {
106    SmartGraph G;
107    addPetersen(G);
108    bidirPetersen(G);
109    checkPetersen(G);
110  }
111  {
112    ListGraph G;
113    addPetersen(G);
114    bidirPetersen(G);
115    checkPetersen(G);
116  }
117  {
118    SymSmartGraph G;
119    addPetersen(G);
120    checkPetersen(G);
121  }
122  {
123    SymListGraph G;
124    addPetersen(G);
125    checkPetersen(G);
126  }
127
128  ///\file
129  ///\todo map tests.
130  ///\todo copy constr tests.
131
132  std::cout << __FILE__ ": All tests passed.\n";
133
134  return 0;
135}
Note: See TracBrowser for help on using the repository browser.