alpar@906
|
1 |
/* -*- C++ -*-
|
alpar@906
|
2 |
* src/test/graph_test.cc - Part of HUGOlib, 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>
|
ladanyi@542
|
18 |
#include<hugo/smart_graph.h>
|
alpar@564
|
19 |
#include<hugo/skeletons/graph.h>
|
alpar@578
|
20 |
#include<hugo/list_graph.h>
|
alpar@592
|
21 |
#include<hugo/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@503
|
36 |
using namespace hugo;
|
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@919
|
66 |
++n;
|
alpar@503
|
67 |
}
|
alpar@503
|
68 |
}
|
alpar@503
|
69 |
|
alpar@880
|
70 |
//Compile Graph
|
alpar@880
|
71 |
template void hugo::checkCompileStaticGraph<skeleton::StaticGraph>
|
alpar@880
|
72 |
(skeleton::StaticGraph &);
|
alpar@793
|
73 |
|
alpar@880
|
74 |
template void hugo::checkCompileGraph<skeleton::ExtendableGraph>
|
alpar@880
|
75 |
(skeleton::ExtendableGraph &);
|
alpar@793
|
76 |
|
alpar@880
|
77 |
template void hugo::checkCompileErasableGraph<skeleton::ErasableGraph>
|
alpar@880
|
78 |
(skeleton::ErasableGraph &);
|
alpar@733
|
79 |
|
alpar@774
|
80 |
//Compile SmartGraph
|
alpar@873
|
81 |
template void hugo::checkCompileGraph<SmartGraph>(SmartGraph &);
|
alpar@873
|
82 |
template void hugo::checkCompileGraphFindEdge<SmartGraph>(SmartGraph &);
|
deba@783
|
83 |
|
alpar@774
|
84 |
//Compile SymSmartGraph
|
alpar@919
|
85 |
template void hugo::checkCompileGraph<SymSmartGraph>(SymSmartGraph &);
|
alpar@919
|
86 |
template void hugo::checkCompileGraphFindEdge<SymSmartGraph>(SymSmartGraph &);
|
alpar@774
|
87 |
|
alpar@774
|
88 |
//Compile ListGraph
|
alpar@873
|
89 |
template void hugo::checkCompileGraph<ListGraph>(ListGraph &);
|
alpar@873
|
90 |
template void hugo::checkCompileErasableGraph<ListGraph>(ListGraph &);
|
alpar@873
|
91 |
template void hugo::checkCompileGraphFindEdge<ListGraph>(ListGraph &);
|
alpar@774
|
92 |
|
deba@783
|
93 |
|
alpar@774
|
94 |
//Compile SymListGraph
|
alpar@919
|
95 |
template void hugo::checkCompileGraph<SymListGraph>(SymListGraph &);
|
alpar@919
|
96 |
template void hugo::checkCompileErasableGraph<SymListGraph>(SymListGraph &);
|
alpar@919
|
97 |
template void hugo::checkCompileGraphFindEdge<SymListGraph>(SymListGraph &);
|
alpar@774
|
98 |
|
alpar@774
|
99 |
//Compile FullGraph
|
alpar@873
|
100 |
template void hugo::checkCompileStaticGraph<FullGraph>(FullGraph &);
|
alpar@873
|
101 |
template void hugo::checkCompileGraphFindEdge<FullGraph>(FullGraph &);
|
alpar@550
|
102 |
|
alpar@774
|
103 |
//Compile EdgeSet <ListGraph>
|
alpar@873
|
104 |
template void hugo::checkCompileGraph<EdgeSet <ListGraph> >
|
alpar@800
|
105 |
(EdgeSet <ListGraph> &);
|
alpar@873
|
106 |
template void hugo::checkCompileGraphEraseEdge<EdgeSet <ListGraph> >
|
alpar@873
|
107 |
(EdgeSet <ListGraph> &);
|
alpar@873
|
108 |
template void hugo::checkCompileGraphFindEdge<EdgeSet <ListGraph> >
|
alpar@800
|
109 |
(EdgeSet <ListGraph> &);
|
alpar@774
|
110 |
|
alpar@774
|
111 |
//Compile EdgeSet <NodeSet>
|
alpar@873
|
112 |
template void hugo::checkCompileGraph<EdgeSet <NodeSet> >(EdgeSet <NodeSet> &);
|
alpar@873
|
113 |
template void hugo::checkCompileGraphEraseEdge<EdgeSet <NodeSet> >
|
alpar@800
|
114 |
(EdgeSet <NodeSet> &);
|
alpar@873
|
115 |
template void hugo::checkCompileGraphFindEdge<EdgeSet <NodeSet> >
|
alpar@800
|
116 |
(EdgeSet <NodeSet> &);
|
alpar@774
|
117 |
|
alpar@503
|
118 |
|
alpar@503
|
119 |
int main()
|
alpar@503
|
120 |
{
|
alpar@503
|
121 |
{
|
alpar@503
|
122 |
SmartGraph G;
|
alpar@503
|
123 |
addPetersen(G);
|
alpar@503
|
124 |
bidirPetersen(G);
|
alpar@503
|
125 |
checkPetersen(G);
|
alpar@503
|
126 |
}
|
alpar@578
|
127 |
{
|
alpar@578
|
128 |
ListGraph G;
|
alpar@578
|
129 |
addPetersen(G);
|
alpar@578
|
130 |
bidirPetersen(G);
|
alpar@578
|
131 |
checkPetersen(G);
|
alpar@578
|
132 |
}
|
alpar@503
|
133 |
{
|
alpar@919
|
134 |
SymSmartGraph G;
|
alpar@919
|
135 |
addPetersen(G);
|
alpar@919
|
136 |
checkPetersen(G);
|
alpar@503
|
137 |
}
|
alpar@578
|
138 |
{
|
alpar@919
|
139 |
SymListGraph G;
|
alpar@919
|
140 |
addPetersen(G);
|
alpar@919
|
141 |
checkPetersen(G);
|
alpar@578
|
142 |
}
|
alpar@503
|
143 |
|
alpar@774
|
144 |
///\file
|
alpar@774
|
145 |
///\todo map tests.
|
alpar@774
|
146 |
///\todo copy constr tests.
|
alpar@503
|
147 |
|
alpar@503
|
148 |
std::cout << __FILE__ ": All tests passed.\n";
|
alpar@503
|
149 |
|
alpar@579
|
150 |
return 0;
|
alpar@503
|
151 |
}
|