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