1 /* -*- C++ -*- |
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 |
2 |
17 #include<iostream> |
3 #include <iostream> |
18 #include<lemon/smart_graph.h> |
4 #include <vector> |
19 #include<lemon/skeletons/graph.h> |
|
20 #include<lemon/list_graph.h> |
|
21 #include<lemon/full_graph.h> |
|
22 |
5 |
23 #include"test_tools.h" |
6 #include <lemon/skeletons/graph.h> |
24 #include"graph_test.h" |
7 #include <lemon/list_graph.h> |
|
8 #include <lemon/smart_graph.h> |
|
9 #include <lemon/full_graph.h> |
25 |
10 |
26 /** |
11 #include "test_tools.h" |
27 \file |
12 #include "graph_test.h" |
28 This test makes consistency checks of list graph structures. |
13 #include "map_test.h" |
29 |
14 |
30 G.addNode(), G.addEdge(), G.tail(), G.head() |
|
31 |
|
32 \todo Checks for empty graphs and isolated points. |
|
33 conversion. |
|
34 */ |
|
35 |
15 |
36 using namespace lemon; |
16 using namespace lemon; |
37 |
17 using namespace lemon::skeleton; |
38 template<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 |
|
53 template<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 } |
|
67 } |
|
68 |
|
69 //Compile Graph |
|
70 template void lemon::skeleton::checkCompileStaticGraph<skeleton::StaticGraph> |
|
71 (skeleton::StaticGraph &); |
|
72 |
|
73 template |
|
74 void lemon::skeleton::checkCompileExtendableGraph<skeleton::ExtendableGraph> |
|
75 (skeleton::ExtendableGraph &); |
|
76 |
|
77 template |
|
78 void lemon::skeleton::checkCompileErasableGraph<skeleton::ErasableGraph> |
|
79 (skeleton::ErasableGraph &); |
|
80 |
|
81 //Compile SmartGraph |
|
82 template |
|
83 void lemon::skeleton::checkCompileExtendableGraph<SmartGraph>(SmartGraph &); |
|
84 template |
|
85 void lemon::skeleton::checkCompileGraphFindEdge<SmartGraph>(SmartGraph &); |
|
86 |
|
87 //Compile SymSmartGraph |
|
88 //template void hugo::checkCompileGraph<SymSmartGraph>(SymSmartGraph &); |
|
89 //template void hugo::checkCompileGraphFindEdge<SymSmartGraph>(SymSmartGraph &); |
|
90 |
|
91 //Compile ListGraph |
|
92 template |
|
93 void lemon::skeleton::checkCompileExtendableGraph<ListGraph>(ListGraph &); |
|
94 template |
|
95 void lemon::skeleton::checkCompileErasableGraph<ListGraph>(ListGraph &); |
|
96 template |
|
97 void lemon::skeleton::checkCompileGraphFindEdge<ListGraph>(ListGraph &); |
|
98 |
18 |
99 |
19 |
100 //Compile SymListGraph |
20 int main() { |
101 //template void hugo::checkCompileGraph<SymListGraph>(SymListGraph &); |
21 ///\file |
102 //template void hugo::checkCompileErasableGraph<SymListGraph>(SymListGraph &); |
22 { // checking graph components |
103 //template void hugo::checkCompileGraphFindEdge<SymListGraph>(SymListGraph &); |
23 function_requires<BaseGraphComponentConcept<BaseGraphComponent> >(); |
104 |
24 |
105 //Compile FullGraph |
25 function_requires<BaseIterableGraphComponentConcept<BaseIterableGraphComponent> >(); |
106 template void lemon::skeleton::checkCompileStaticGraph<FullGraph>(FullGraph &); |
|
107 template |
|
108 void lemon::skeleton::checkCompileGraphFindEdge<FullGraph>(FullGraph &); |
|
109 |
26 |
110 //Compile EdgeSet <ListGraph> |
27 function_requires<IDableGraphComponentConcept<IDableGraphComponent> >(); |
111 template void lemon::skeleton::checkCompileExtendableGraph<EdgeSet <ListGraph> > |
28 function_requires<MaxIDableGraphComponentConcept<MaxIDableGraphComponent> >(); |
112 (EdgeSet <ListGraph> &); |
|
113 template void lemon::skeleton::checkCompileGraphEraseEdge<EdgeSet <ListGraph> > |
|
114 (EdgeSet <ListGraph> &); |
|
115 template void lemon::skeleton::checkCompileGraphFindEdge<EdgeSet <ListGraph> > |
|
116 (EdgeSet <ListGraph> &); |
|
117 |
29 |
118 //Compile EdgeSet <NodeSet> |
30 function_requires<BaseExtendableGraphComponentConcept<BaseExtendableGraphComponent> >(); |
119 template void lemon::skeleton::checkCompileExtendableGraph<EdgeSet <NodeSet> > |
31 function_requires<BaseErasableGraphComponentConcept<BaseErasableGraphComponent> >(); |
120 (EdgeSet <NodeSet> &); |
32 function_requires<BaseClearableGraphComponentConcept<BaseClearableGraphComponent> >(); |
121 template void lemon::skeleton::checkCompileGraphEraseEdge<EdgeSet <NodeSet> > |
|
122 (EdgeSet <NodeSet> &); |
|
123 template void lemon::skeleton::checkCompileGraphFindEdge<EdgeSet <NodeSet> > |
|
124 (EdgeSet <NodeSet> &); |
|
125 |
33 |
|
34 function_requires<IterableGraphComponentConcept<IterableGraphComponent> >(); |
126 |
35 |
127 int main() |
36 function_requires<IdMappableGraphComponentConcept<IdMappableGraphComponent> >(); |
128 { |
37 function_requires<MappableGraphComponentConcept<MappableGraphComponent> >(); |
129 { |
38 |
130 SmartGraph G; |
39 function_requires<ExtendableGraphComponentConcept<ExtendableGraphComponent> >(); |
131 addPetersen(G); |
40 function_requires<ErasableGraphComponentConcept<ErasableGraphComponent> >(); |
132 bidirPetersen(G); |
41 function_requires<ClearableGraphComponentConcept<ClearableGraphComponent> >(); |
133 checkPetersen(G); |
|
134 } |
42 } |
135 { |
43 { // checking skeleton graphs |
136 ListGraph G; |
44 function_requires<StaticGraphConcept<StaticGraph> >(); |
137 addPetersen(G); |
45 function_requires<ExtendableGraphConcept<ExtendableGraph> >(); |
138 bidirPetersen(G); |
46 function_requires<ErasableGraphConcept<ErasableGraph> >(); |
139 checkPetersen(G); |
|
140 } |
47 } |
141 { |
48 { // checking list graph |
142 // SymSmartGraph G; |
49 function_requires<ErasableGraphConcept<ListGraph> >(); |
143 // addPetersen(G); |
50 |
144 // checkPetersen(G); |
51 checkGraph<ListGraph>(); |
|
52 checkGraphNodeMap<ListGraph>(); |
|
53 checkGraphEdgeMap<ListGraph>(); |
145 } |
54 } |
146 { |
55 { // checking smart graph |
147 // SymListGraph G; |
56 function_requires<ExtendableGraphConcept<SmartGraph> >(); |
148 // addPetersen(G); |
57 |
149 // checkPetersen(G); |
58 checkGraph<SmartGraph>(); |
|
59 checkGraphNodeMap<SmartGraph>(); |
|
60 checkGraphEdgeMap<SmartGraph>(); |
150 } |
61 } |
151 |
62 { // checking full graph |
152 ///\file |
63 function_requires<StaticGraphConcept<FullGraph> >(); |
153 ///\todo map tests. |
64 } |
154 ///\todo copy constr tests. |
|
155 |
65 |
156 std::cout << __FILE__ ": All tests passed.\n"; |
66 std::cout << __FILE__ ": All tests passed.\n"; |
157 |
67 |
158 return 0; |
68 return 0; |
159 } |
69 } |