alpar@906
|
1 |
/* -*- C++ -*-
|
alpar@921
|
2 |
* src/test/graph_test.cc - Part of LEMON, a generic C++ optimization library
|
alpar@906
|
3 |
*
|
alpar@906
|
4 |
* Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
|
alpar@906
|
5 |
* (Egervary Combinatorial Optimization Research Group, EGRES).
|
alpar@906
|
6 |
*
|
alpar@906
|
7 |
* Permission to use, modify and distribute this software is granted
|
alpar@906
|
8 |
* provided that this copyright notice appears in all copies. For
|
alpar@906
|
9 |
* precise terms see the accompanying LICENSE file.
|
alpar@906
|
10 |
*
|
alpar@906
|
11 |
* This software is provided "AS IS" with no warranty of any kind,
|
alpar@906
|
12 |
* express or implied, and with no claim as to its suitability for any
|
alpar@906
|
13 |
* purpose.
|
alpar@906
|
14 |
*
|
alpar@906
|
15 |
*/
|
alpar@906
|
16 |
|
alpar@503
|
17 |
#include<iostream>
|
alpar@921
|
18 |
#include<lemon/smart_graph.h>
|
alpar@921
|
19 |
#include<lemon/skeletons/graph.h>
|
alpar@921
|
20 |
#include<lemon/list_graph.h>
|
alpar@921
|
21 |
#include<lemon/full_graph.h>
|
alpar@578
|
22 |
|
alpar@567
|
23 |
#include"test_tools.h"
|
alpar@800
|
24 |
#include"graph_test.h"
|
alpar@567
|
25 |
|
alpar@774
|
26 |
/**
|
alpar@774
|
27 |
\file
|
alpar@503
|
28 |
This test makes consistency checks of list graph structures.
|
alpar@503
|
29 |
|
alpar@774
|
30 |
G.addNode(), G.addEdge(), G.tail(), G.head()
|
alpar@503
|
31 |
|
alpar@592
|
32 |
\todo Checks for empty graphs and isolated points.
|
alpar@774
|
33 |
conversion.
|
alpar@503
|
34 |
*/
|
alpar@503
|
35 |
|
alpar@921
|
36 |
using namespace lemon;
|
alpar@503
|
37 |
|
alpar@503
|
38 |
template<class Graph> void bidirPetersen(Graph &G)
|
alpar@503
|
39 |
{
|
alpar@503
|
40 |
typedef typename Graph::Edge Edge;
|
alpar@503
|
41 |
typedef typename Graph::EdgeIt EdgeIt;
|
alpar@503
|
42 |
|
alpar@800
|
43 |
checkGraphEdgeList(G,15);
|
alpar@503
|
44 |
|
alpar@503
|
45 |
std::vector<Edge> ee;
|
alpar@503
|
46 |
|
alpar@774
|
47 |
for(EdgeIt e(G);e!=INVALID;++e) ee.push_back(e);
|
alpar@503
|
48 |
|
alpar@503
|
49 |
for(typename std::vector<Edge>::iterator p=ee.begin();p!=ee.end();p++)
|
alpar@503
|
50 |
G.addEdge(G.head(*p),G.tail(*p));
|
alpar@503
|
51 |
}
|
alpar@503
|
52 |
|
alpar@503
|
53 |
template<class Graph> void checkPetersen(Graph &G)
|
alpar@503
|
54 |
{
|
alpar@503
|
55 |
typedef typename Graph::Node Node;
|
alpar@503
|
56 |
|
alpar@503
|
57 |
typedef typename Graph::EdgeIt EdgeIt;
|
alpar@503
|
58 |
typedef typename Graph::NodeIt NodeIt;
|
alpar@503
|
59 |
|
alpar@800
|
60 |
checkGraphNodeList(G,10);
|
alpar@800
|
61 |
checkGraphEdgeList(G,30);
|
alpar@503
|
62 |
|
alpar@774
|
63 |
for(NodeIt n(G);n!=INVALID;++n) {
|
alpar@800
|
64 |
checkGraphInEdgeList(G,n,3);
|
alpar@800
|
65 |
checkGraphOutEdgeList(G,n,3);
|
alpar@503
|
66 |
}
|
alpar@503
|
67 |
}
|
alpar@503
|
68 |
|
alpar@880
|
69 |
//Compile Graph
|
alpar@938
|
70 |
template void lemon::skeleton::checkCompileStaticGraph<skeleton::StaticGraph>
|
alpar@880
|
71 |
(skeleton::StaticGraph &);
|
alpar@793
|
72 |
|
alpar@938
|
73 |
template
|
alpar@938
|
74 |
void lemon::skeleton::checkCompileExtendableGraph<skeleton::ExtendableGraph>
|
alpar@880
|
75 |
(skeleton::ExtendableGraph &);
|
alpar@793
|
76 |
|
alpar@938
|
77 |
template
|
alpar@938
|
78 |
void lemon::skeleton::checkCompileErasableGraph<skeleton::ErasableGraph>
|
alpar@880
|
79 |
(skeleton::ErasableGraph &);
|
alpar@733
|
80 |
|
alpar@774
|
81 |
//Compile SmartGraph
|
alpar@938
|
82 |
template
|
alpar@938
|
83 |
void lemon::skeleton::checkCompileExtendableGraph<SmartGraph>(SmartGraph &);
|
alpar@938
|
84 |
template
|
alpar@938
|
85 |
void lemon::skeleton::checkCompileGraphFindEdge<SmartGraph>(SmartGraph &);
|
deba@783
|
86 |
|
alpar@774
|
87 |
//Compile SymSmartGraph
|
deba@937
|
88 |
//template void hugo::checkCompileGraph<SymSmartGraph>(SymSmartGraph &);
|
deba@937
|
89 |
//template void hugo::checkCompileGraphFindEdge<SymSmartGraph>(SymSmartGraph &);
|
alpar@774
|
90 |
|
alpar@774
|
91 |
//Compile ListGraph
|
alpar@938
|
92 |
template
|
alpar@938
|
93 |
void lemon::skeleton::checkCompileExtendableGraph<ListGraph>(ListGraph &);
|
alpar@938
|
94 |
template
|
alpar@938
|
95 |
void lemon::skeleton::checkCompileErasableGraph<ListGraph>(ListGraph &);
|
alpar@938
|
96 |
template
|
alpar@938
|
97 |
void lemon::skeleton::checkCompileGraphFindEdge<ListGraph>(ListGraph &);
|
alpar@774
|
98 |
|
deba@783
|
99 |
|
alpar@774
|
100 |
//Compile SymListGraph
|
deba@937
|
101 |
//template void hugo::checkCompileGraph<SymListGraph>(SymListGraph &);
|
deba@937
|
102 |
//template void hugo::checkCompileErasableGraph<SymListGraph>(SymListGraph &);
|
deba@937
|
103 |
//template void hugo::checkCompileGraphFindEdge<SymListGraph>(SymListGraph &);
|
alpar@774
|
104 |
|
alpar@774
|
105 |
//Compile FullGraph
|
alpar@938
|
106 |
template void lemon::skeleton::checkCompileStaticGraph<FullGraph>(FullGraph &);
|
alpar@938
|
107 |
template
|
alpar@938
|
108 |
void lemon::skeleton::checkCompileGraphFindEdge<FullGraph>(FullGraph &);
|
alpar@550
|
109 |
|
alpar@774
|
110 |
//Compile EdgeSet <ListGraph>
|
alpar@938
|
111 |
template void lemon::skeleton::checkCompileExtendableGraph<EdgeSet <ListGraph> >
|
alpar@800
|
112 |
(EdgeSet <ListGraph> &);
|
alpar@938
|
113 |
template void lemon::skeleton::checkCompileGraphEraseEdge<EdgeSet <ListGraph> >
|
alpar@873
|
114 |
(EdgeSet <ListGraph> &);
|
alpar@938
|
115 |
template void lemon::skeleton::checkCompileGraphFindEdge<EdgeSet <ListGraph> >
|
alpar@800
|
116 |
(EdgeSet <ListGraph> &);
|
alpar@774
|
117 |
|
alpar@774
|
118 |
//Compile EdgeSet <NodeSet>
|
alpar@938
|
119 |
template void lemon::skeleton::checkCompileExtendableGraph<EdgeSet <NodeSet> >
|
alpar@800
|
120 |
(EdgeSet <NodeSet> &);
|
alpar@938
|
121 |
template void lemon::skeleton::checkCompileGraphEraseEdge<EdgeSet <NodeSet> >
|
alpar@938
|
122 |
(EdgeSet <NodeSet> &);
|
alpar@938
|
123 |
template void lemon::skeleton::checkCompileGraphFindEdge<EdgeSet <NodeSet> >
|
alpar@800
|
124 |
(EdgeSet <NodeSet> &);
|
alpar@774
|
125 |
|
alpar@503
|
126 |
|
alpar@503
|
127 |
int main()
|
alpar@503
|
128 |
{
|
alpar@503
|
129 |
{
|
alpar@503
|
130 |
SmartGraph G;
|
alpar@503
|
131 |
addPetersen(G);
|
alpar@503
|
132 |
bidirPetersen(G);
|
alpar@503
|
133 |
checkPetersen(G);
|
alpar@503
|
134 |
}
|
alpar@578
|
135 |
{
|
alpar@578
|
136 |
ListGraph G;
|
alpar@578
|
137 |
addPetersen(G);
|
alpar@578
|
138 |
bidirPetersen(G);
|
alpar@578
|
139 |
checkPetersen(G);
|
alpar@578
|
140 |
}
|
alpar@503
|
141 |
{
|
deba@937
|
142 |
// SymSmartGraph G;
|
deba@937
|
143 |
// addPetersen(G);
|
deba@937
|
144 |
// checkPetersen(G);
|
alpar@503
|
145 |
}
|
alpar@578
|
146 |
{
|
deba@937
|
147 |
// SymListGraph G;
|
deba@937
|
148 |
// addPetersen(G);
|
deba@937
|
149 |
// checkPetersen(G);
|
alpar@578
|
150 |
}
|
alpar@503
|
151 |
|
alpar@774
|
152 |
///\file
|
alpar@774
|
153 |
///\todo map tests.
|
alpar@774
|
154 |
///\todo copy constr tests.
|
alpar@503
|
155 |
|
alpar@503
|
156 |
std::cout << __FILE__ ": All tests passed.\n";
|
alpar@503
|
157 |
|
alpar@579
|
158 |
return 0;
|
alpar@503
|
159 |
}
|