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@921
|
70 |
template void lemon::checkCompileStaticGraph<skeleton::StaticGraph>
|
alpar@880
|
71 |
(skeleton::StaticGraph &);
|
alpar@793
|
72 |
|
alpar@921
|
73 |
template void lemon::checkCompileGraph<skeleton::ExtendableGraph>
|
alpar@880
|
74 |
(skeleton::ExtendableGraph &);
|
alpar@793
|
75 |
|
alpar@921
|
76 |
template void lemon::checkCompileErasableGraph<skeleton::ErasableGraph>
|
alpar@880
|
77 |
(skeleton::ErasableGraph &);
|
alpar@733
|
78 |
|
alpar@774
|
79 |
//Compile SmartGraph
|
alpar@921
|
80 |
template void lemon::checkCompileGraph<SmartGraph>(SmartGraph &);
|
alpar@921
|
81 |
template void lemon::checkCompileGraphFindEdge<SmartGraph>(SmartGraph &);
|
deba@783
|
82 |
|
alpar@774
|
83 |
//Compile SymSmartGraph
|
deba@937
|
84 |
//template void hugo::checkCompileGraph<SymSmartGraph>(SymSmartGraph &);
|
deba@937
|
85 |
//template void hugo::checkCompileGraphFindEdge<SymSmartGraph>(SymSmartGraph &);
|
alpar@774
|
86 |
|
alpar@774
|
87 |
//Compile ListGraph
|
alpar@921
|
88 |
template void lemon::checkCompileGraph<ListGraph>(ListGraph &);
|
alpar@921
|
89 |
template void lemon::checkCompileErasableGraph<ListGraph>(ListGraph &);
|
alpar@921
|
90 |
template void lemon::checkCompileGraphFindEdge<ListGraph>(ListGraph &);
|
alpar@774
|
91 |
|
deba@783
|
92 |
|
alpar@774
|
93 |
//Compile SymListGraph
|
deba@937
|
94 |
//template void hugo::checkCompileGraph<SymListGraph>(SymListGraph &);
|
deba@937
|
95 |
//template void hugo::checkCompileErasableGraph<SymListGraph>(SymListGraph &);
|
deba@937
|
96 |
//template void hugo::checkCompileGraphFindEdge<SymListGraph>(SymListGraph &);
|
alpar@774
|
97 |
|
alpar@774
|
98 |
//Compile FullGraph
|
alpar@921
|
99 |
template void lemon::checkCompileStaticGraph<FullGraph>(FullGraph &);
|
alpar@921
|
100 |
template void lemon::checkCompileGraphFindEdge<FullGraph>(FullGraph &);
|
alpar@550
|
101 |
|
alpar@774
|
102 |
//Compile EdgeSet <ListGraph>
|
alpar@921
|
103 |
template void lemon::checkCompileGraph<EdgeSet <ListGraph> >
|
alpar@800
|
104 |
(EdgeSet <ListGraph> &);
|
alpar@921
|
105 |
template void lemon::checkCompileGraphEraseEdge<EdgeSet <ListGraph> >
|
alpar@873
|
106 |
(EdgeSet <ListGraph> &);
|
alpar@921
|
107 |
template void lemon::checkCompileGraphFindEdge<EdgeSet <ListGraph> >
|
alpar@800
|
108 |
(EdgeSet <ListGraph> &);
|
alpar@774
|
109 |
|
alpar@774
|
110 |
//Compile EdgeSet <NodeSet>
|
alpar@921
|
111 |
template void lemon::checkCompileGraph<EdgeSet <NodeSet> >(EdgeSet <NodeSet> &);
|
alpar@921
|
112 |
template void lemon::checkCompileGraphEraseEdge<EdgeSet <NodeSet> >
|
alpar@800
|
113 |
(EdgeSet <NodeSet> &);
|
alpar@921
|
114 |
template void lemon::checkCompileGraphFindEdge<EdgeSet <NodeSet> >
|
alpar@800
|
115 |
(EdgeSet <NodeSet> &);
|
alpar@774
|
116 |
|
alpar@503
|
117 |
|
alpar@503
|
118 |
int main()
|
alpar@503
|
119 |
{
|
alpar@503
|
120 |
{
|
alpar@503
|
121 |
SmartGraph G;
|
alpar@503
|
122 |
addPetersen(G);
|
alpar@503
|
123 |
bidirPetersen(G);
|
alpar@503
|
124 |
checkPetersen(G);
|
alpar@503
|
125 |
}
|
alpar@578
|
126 |
{
|
alpar@578
|
127 |
ListGraph G;
|
alpar@578
|
128 |
addPetersen(G);
|
alpar@578
|
129 |
bidirPetersen(G);
|
alpar@578
|
130 |
checkPetersen(G);
|
alpar@578
|
131 |
}
|
alpar@503
|
132 |
{
|
deba@937
|
133 |
// SymSmartGraph G;
|
deba@937
|
134 |
// addPetersen(G);
|
deba@937
|
135 |
// checkPetersen(G);
|
alpar@503
|
136 |
}
|
alpar@578
|
137 |
{
|
deba@937
|
138 |
// SymListGraph G;
|
deba@937
|
139 |
// addPetersen(G);
|
deba@937
|
140 |
// checkPetersen(G);
|
alpar@578
|
141 |
}
|
alpar@503
|
142 |
|
alpar@774
|
143 |
///\file
|
alpar@774
|
144 |
///\todo map tests.
|
alpar@774
|
145 |
///\todo copy constr tests.
|
alpar@503
|
146 |
|
alpar@503
|
147 |
std::cout << __FILE__ ": All tests passed.\n";
|
alpar@503
|
148 |
|
alpar@579
|
149 |
return 0;
|
alpar@503
|
150 |
}
|