|
1 /* -*- C++ -*- |
|
2 * src/test/graph_test.cc - Part of LEMON, 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<lemon/smart_graph.h> |
|
19 #include<lemon/skeletons/graph.h> |
|
20 #include<lemon/skeletons/maps.h> |
|
21 #include<lemon/list_graph_base.h> |
|
22 #include<lemon/full_graph.h> |
|
23 |
|
24 #include"test_tools.h" |
|
25 #include"graph_test.h" |
|
26 |
|
27 /** |
|
28 \file |
|
29 This test makes consistency checks of list graph structures. |
|
30 |
|
31 G.addNode(), G.addEdge(), G.tail(), G.head() |
|
32 |
|
33 \todo Checks for empty graphs and isolated points. |
|
34 conversion. |
|
35 */ |
|
36 |
|
37 using namespace lemon; |
|
38 |
|
39 template<class Graph> void bidirPetersen(Graph &G) |
|
40 { |
|
41 typedef typename Graph::Edge Edge; |
|
42 typedef typename Graph::EdgeIt EdgeIt; |
|
43 |
|
44 checkGraphEdgeList(G,15); |
|
45 |
|
46 std::vector<Edge> ee; |
|
47 |
|
48 for(EdgeIt e(G);e!=INVALID;++e) ee.push_back(e); |
|
49 |
|
50 for(typename std::vector<Edge>::iterator p=ee.begin();p!=ee.end();p++) |
|
51 G.addEdge(G.head(*p),G.tail(*p)); |
|
52 } |
|
53 |
|
54 template<class Graph> void checkPetersen(Graph &G) |
|
55 { |
|
56 typedef typename Graph::Node Node; |
|
57 |
|
58 typedef typename Graph::EdgeIt EdgeIt; |
|
59 typedef typename Graph::NodeIt NodeIt; |
|
60 |
|
61 checkGraphNodeList(G,10); |
|
62 checkGraphEdgeList(G,30); |
|
63 |
|
64 for(NodeIt n(G);n!=INVALID;++n) { |
|
65 checkGraphInEdgeList(G,n,3); |
|
66 checkGraphOutEdgeList(G,n,3); |
|
67 } |
|
68 } |
|
69 |
|
70 //Compile Graph |
|
71 template void lemon::skeleton::checkCompileStaticGraph<skeleton::StaticGraph> |
|
72 (skeleton::StaticGraph &); |
|
73 |
|
74 template |
|
75 void lemon::skeleton::checkCompileExtendableGraph<skeleton::ExtendableGraph> |
|
76 (skeleton::ExtendableGraph &); |
|
77 |
|
78 template |
|
79 void lemon::skeleton::checkCompileErasableGraph<skeleton::ErasableGraph> |
|
80 (skeleton::ErasableGraph &); |
|
81 |
|
82 //Compile SmartGraph |
|
83 template |
|
84 void lemon::skeleton::checkCompileExtendableGraph<SmartGraph>(SmartGraph &); |
|
85 template |
|
86 void lemon::skeleton::checkCompileGraphFindEdge<SmartGraph>(SmartGraph &); |
|
87 |
|
88 //Compile SymSmartGraph |
|
89 //template void hugo::checkCompileGraph<SymSmartGraph>(SymSmartGraph &); |
|
90 //template void hugo::checkCompileGraphFindEdge<SymSmartGraph>(SymSmartGraph &); |
|
91 |
|
92 //Compile ListGraph |
|
93 template |
|
94 void lemon::skeleton::checkCompileExtendableGraph<ListGraph>(ListGraph &); |
|
95 template |
|
96 void lemon::skeleton::checkCompileErasableGraph<ListGraph>(ListGraph &); |
|
97 template |
|
98 void lemon::skeleton::checkCompileGraphFindEdge<ListGraph>(ListGraph &); |
|
99 |
|
100 |
|
101 //Compile SymListGraph |
|
102 //template void hugo::checkCompileGraph<SymListGraph>(SymListGraph &); |
|
103 //template void hugo::checkCompileErasableGraph<SymListGraph>(SymListGraph &); |
|
104 //template void hugo::checkCompileGraphFindEdge<SymListGraph>(SymListGraph &); |
|
105 |
|
106 //Compile FullGraph |
|
107 template void lemon::skeleton::checkCompileStaticGraph<FullGraph>(FullGraph &); |
|
108 template |
|
109 void lemon::skeleton::checkCompileGraphFindEdge<FullGraph>(FullGraph &); |
|
110 |
|
111 |
|
112 int main() |
|
113 { |
|
114 { |
|
115 SmartGraph G; |
|
116 addPetersen(G); |
|
117 bidirPetersen(G); |
|
118 checkPetersen(G); |
|
119 } |
|
120 { |
|
121 ListGraph G; |
|
122 addPetersen(G); |
|
123 bidirPetersen(G); |
|
124 checkPetersen(G); |
|
125 } |
|
126 { |
|
127 // SymSmartGraph G; |
|
128 // addPetersen(G); |
|
129 // checkPetersen(G); |
|
130 } |
|
131 { |
|
132 // SymListGraph G; |
|
133 // addPetersen(G); |
|
134 // checkPetersen(G); |
|
135 } |
|
136 |
|
137 ///\file |
|
138 ///\todo map tests. |
|
139 ///\todo copy constr tests. |
|
140 |
|
141 |
|
142 // Some map tests. |
|
143 // FIXME: These shouldn't be here. |
|
144 using namespace skeleton; |
|
145 function_requires< ReadMapConcept< ReadMap<int,int> > >(); |
|
146 function_requires< WriteMapConcept< WriteMap<int,int> > >(); |
|
147 function_requires< ReadWriteMapConcept< ReadWriteMap<int,int> > >(); |
|
148 function_requires< ReferenceMapConcept< ReferenceMap<int,int> > >(); |
|
149 |
|
150 |
|
151 std::cout << __FILE__ ": All tests passed.\n"; |
|
152 |
|
153 return 0; |
|
154 } |