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