williamr@2
|
1 |
//
|
williamr@2
|
2 |
//=======================================================================
|
williamr@2
|
3 |
// Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
|
williamr@2
|
4 |
// Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek
|
williamr@2
|
5 |
//
|
williamr@2
|
6 |
// Distributed under the Boost Software License, Version 1.0. (See
|
williamr@2
|
7 |
// accompanying file LICENSE_1_0.txt or copy at
|
williamr@2
|
8 |
// http://www.boost.org/LICENSE_1_0.txt)
|
williamr@2
|
9 |
//=======================================================================
|
williamr@2
|
10 |
//
|
williamr@2
|
11 |
#ifndef BOOST_GRAPH_CONCEPTS_HPP
|
williamr@2
|
12 |
#define BOOST_GRAPH_CONCEPTS_HPP
|
williamr@2
|
13 |
|
williamr@2
|
14 |
#include <boost/config.hpp>
|
williamr@2
|
15 |
#include <boost/graph/graph_traits.hpp>
|
williamr@2
|
16 |
#include <boost/property_map.hpp>
|
williamr@2
|
17 |
#include <boost/graph/properties.hpp>
|
williamr@2
|
18 |
#include <boost/concept_check.hpp>
|
williamr@2
|
19 |
#include <boost/detail/workaround.hpp>
|
williamr@2
|
20 |
|
williamr@2
|
21 |
namespace boost {
|
williamr@2
|
22 |
|
williamr@2
|
23 |
template <class T>
|
williamr@2
|
24 |
struct MultiPassInputIteratorConcept {
|
williamr@2
|
25 |
void constraints() {
|
williamr@2
|
26 |
function_requires< InputIteratorConcept<T> >();
|
williamr@2
|
27 |
}
|
williamr@2
|
28 |
};
|
williamr@2
|
29 |
|
williamr@2
|
30 |
template <class G>
|
williamr@2
|
31 |
struct GraphConcept
|
williamr@2
|
32 |
{
|
williamr@2
|
33 |
typedef typename graph_traits<G>::vertex_descriptor vertex_descriptor;
|
williamr@2
|
34 |
typedef typename graph_traits<G>::directed_category directed_category;
|
williamr@2
|
35 |
typedef typename graph_traits<G>::edge_parallel_category
|
williamr@2
|
36 |
edge_parallel_category;
|
williamr@2
|
37 |
typedef typename graph_traits<G>::traversal_category
|
williamr@2
|
38 |
traversal_category;
|
williamr@2
|
39 |
void constraints() {
|
williamr@2
|
40 |
function_requires< DefaultConstructibleConcept<vertex_descriptor> >();
|
williamr@2
|
41 |
function_requires< EqualityComparableConcept<vertex_descriptor> >();
|
williamr@2
|
42 |
function_requires< AssignableConcept<vertex_descriptor> >();
|
williamr@2
|
43 |
}
|
williamr@2
|
44 |
G g;
|
williamr@2
|
45 |
};
|
williamr@2
|
46 |
|
williamr@2
|
47 |
template <class G>
|
williamr@2
|
48 |
struct IncidenceGraphConcept
|
williamr@2
|
49 |
{
|
williamr@2
|
50 |
typedef typename graph_traits<G>::edge_descriptor edge_descriptor;
|
williamr@2
|
51 |
typedef typename graph_traits<G>::out_edge_iterator
|
williamr@2
|
52 |
out_edge_iterator;
|
williamr@2
|
53 |
typedef typename graph_traits<G>::traversal_category
|
williamr@2
|
54 |
traversal_category;
|
williamr@2
|
55 |
void constraints() {
|
williamr@2
|
56 |
function_requires< GraphConcept<G> >();
|
williamr@2
|
57 |
function_requires< MultiPassInputIteratorConcept<out_edge_iterator> >();
|
williamr@2
|
58 |
function_requires< DefaultConstructibleConcept<edge_descriptor> >();
|
williamr@2
|
59 |
function_requires< EqualityComparableConcept<edge_descriptor> >();
|
williamr@2
|
60 |
function_requires< AssignableConcept<edge_descriptor> >();
|
williamr@2
|
61 |
function_requires< ConvertibleConcept<traversal_category,
|
williamr@2
|
62 |
incidence_graph_tag> >();
|
williamr@2
|
63 |
|
williamr@2
|
64 |
p = out_edges(u, g);
|
williamr@2
|
65 |
n = out_degree(u, g);
|
williamr@2
|
66 |
e = *p.first;
|
williamr@2
|
67 |
u = source(e, g);
|
williamr@2
|
68 |
v = target(e, g);
|
williamr@2
|
69 |
const_constraints(g);
|
williamr@2
|
70 |
}
|
williamr@2
|
71 |
void const_constraints(const G& cg) {
|
williamr@2
|
72 |
p = out_edges(u, cg);
|
williamr@2
|
73 |
n = out_degree(u, cg);
|
williamr@2
|
74 |
e = *p.first;
|
williamr@2
|
75 |
u = source(e, cg);
|
williamr@2
|
76 |
v = target(e, cg);
|
williamr@2
|
77 |
}
|
williamr@2
|
78 |
std::pair<out_edge_iterator, out_edge_iterator> p;
|
williamr@2
|
79 |
typename graph_traits<G>::vertex_descriptor u, v;
|
williamr@2
|
80 |
typename graph_traits<G>::edge_descriptor e;
|
williamr@2
|
81 |
typename graph_traits<G>::degree_size_type n;
|
williamr@2
|
82 |
G g;
|
williamr@2
|
83 |
};
|
williamr@2
|
84 |
|
williamr@2
|
85 |
template <class G>
|
williamr@2
|
86 |
struct BidirectionalGraphConcept
|
williamr@2
|
87 |
{
|
williamr@2
|
88 |
typedef typename graph_traits<G>::in_edge_iterator
|
williamr@2
|
89 |
in_edge_iterator;
|
williamr@2
|
90 |
typedef typename graph_traits<G>::traversal_category
|
williamr@2
|
91 |
traversal_category;
|
williamr@2
|
92 |
void constraints() {
|
williamr@2
|
93 |
function_requires< IncidenceGraphConcept<G> >();
|
williamr@2
|
94 |
function_requires< MultiPassInputIteratorConcept<in_edge_iterator> >();
|
williamr@2
|
95 |
function_requires< ConvertibleConcept<traversal_category,
|
williamr@2
|
96 |
bidirectional_graph_tag> >();
|
williamr@2
|
97 |
|
williamr@2
|
98 |
p = in_edges(v, g);
|
williamr@2
|
99 |
n = in_degree(v, g);
|
williamr@2
|
100 |
e = *p.first;
|
williamr@2
|
101 |
const_constraints(g);
|
williamr@2
|
102 |
}
|
williamr@2
|
103 |
void const_constraints(const G& cg) {
|
williamr@2
|
104 |
p = in_edges(v, cg);
|
williamr@2
|
105 |
n = in_degree(v, cg);
|
williamr@2
|
106 |
e = *p.first;
|
williamr@2
|
107 |
}
|
williamr@2
|
108 |
std::pair<in_edge_iterator, in_edge_iterator> p;
|
williamr@2
|
109 |
typename graph_traits<G>::vertex_descriptor v;
|
williamr@2
|
110 |
typename graph_traits<G>::edge_descriptor e;
|
williamr@2
|
111 |
typename graph_traits<G>::degree_size_type n;
|
williamr@2
|
112 |
G g;
|
williamr@2
|
113 |
};
|
williamr@2
|
114 |
|
williamr@2
|
115 |
template <class G>
|
williamr@2
|
116 |
struct AdjacencyGraphConcept
|
williamr@2
|
117 |
{
|
williamr@2
|
118 |
typedef typename graph_traits<G>::adjacency_iterator
|
williamr@2
|
119 |
adjacency_iterator;
|
williamr@2
|
120 |
typedef typename graph_traits<G>::traversal_category
|
williamr@2
|
121 |
traversal_category;
|
williamr@2
|
122 |
void constraints() {
|
williamr@2
|
123 |
function_requires< GraphConcept<G> >();
|
williamr@2
|
124 |
function_requires< MultiPassInputIteratorConcept<adjacency_iterator> >();
|
williamr@2
|
125 |
function_requires< ConvertibleConcept<traversal_category,
|
williamr@2
|
126 |
adjacency_graph_tag> >();
|
williamr@2
|
127 |
|
williamr@2
|
128 |
p = adjacent_vertices(v, g);
|
williamr@2
|
129 |
v = *p.first;
|
williamr@2
|
130 |
const_constraints(g);
|
williamr@2
|
131 |
}
|
williamr@2
|
132 |
void const_constraints(const G& cg) {
|
williamr@2
|
133 |
p = adjacent_vertices(v, cg);
|
williamr@2
|
134 |
}
|
williamr@2
|
135 |
std::pair<adjacency_iterator,adjacency_iterator> p;
|
williamr@2
|
136 |
typename graph_traits<G>::vertex_descriptor v;
|
williamr@2
|
137 |
G g;
|
williamr@2
|
138 |
};
|
williamr@2
|
139 |
|
williamr@2
|
140 |
// dwa 2003/7/11 -- This clearly shouldn't be necessary, but if
|
williamr@2
|
141 |
// you want to use vector_as_graph, it is! I'm sure the graph
|
williamr@2
|
142 |
// library leaves these out all over the place. Probably a
|
williamr@2
|
143 |
// redesign involving specializing a template with a static
|
williamr@2
|
144 |
// member function is in order :(
|
williamr@2
|
145 |
//
|
williamr@2
|
146 |
// It is needed in order to allow us to write using boost::vertices as
|
williamr@2
|
147 |
// needed for ADL when using vector_as_graph below.
|
williamr@2
|
148 |
#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) \
|
williamr@2
|
149 |
&& !BOOST_WORKAROUND(__GNUC__, <= 2) \
|
williamr@2
|
150 |
&& !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
williamr@2
|
151 |
# define BOOST_VECTOR_AS_GRAPH_GRAPH_ADL_HACK
|
williamr@2
|
152 |
#endif
|
williamr@2
|
153 |
|
williamr@2
|
154 |
#ifdef BOOST_VECTOR_AS_GRAPH_GRAPH_ADL_HACK
|
williamr@2
|
155 |
template <class T>
|
williamr@2
|
156 |
typename T::ThereReallyIsNoMemberByThisNameInT vertices(T const&);
|
williamr@2
|
157 |
#endif
|
williamr@2
|
158 |
|
williamr@2
|
159 |
template <class G>
|
williamr@2
|
160 |
struct VertexListGraphConcept
|
williamr@2
|
161 |
{
|
williamr@2
|
162 |
typedef typename graph_traits<G>::vertex_iterator vertex_iterator;
|
williamr@2
|
163 |
typedef typename graph_traits<G>::vertices_size_type vertices_size_type;
|
williamr@2
|
164 |
typedef typename graph_traits<G>::traversal_category
|
williamr@2
|
165 |
traversal_category;
|
williamr@2
|
166 |
void constraints() {
|
williamr@2
|
167 |
function_requires< GraphConcept<G> >();
|
williamr@2
|
168 |
function_requires< MultiPassInputIteratorConcept<vertex_iterator> >();
|
williamr@2
|
169 |
function_requires< ConvertibleConcept<traversal_category,
|
williamr@2
|
170 |
vertex_list_graph_tag> >();
|
williamr@2
|
171 |
|
williamr@2
|
172 |
#ifdef BOOST_VECTOR_AS_GRAPH_GRAPH_ADL_HACK
|
williamr@2
|
173 |
// dwa 2003/7/11 -- This clearly shouldn't be necessary, but if
|
williamr@2
|
174 |
// you want to use vector_as_graph, it is! I'm sure the graph
|
williamr@2
|
175 |
// library leaves these out all over the place. Probably a
|
williamr@2
|
176 |
// redesign involving specializing a template with a static
|
williamr@2
|
177 |
// member function is in order :(
|
williamr@2
|
178 |
using boost::vertices;
|
williamr@2
|
179 |
#endif
|
williamr@2
|
180 |
p = vertices(g);
|
williamr@2
|
181 |
v = *p.first;
|
williamr@2
|
182 |
const_constraints(g);
|
williamr@2
|
183 |
}
|
williamr@2
|
184 |
void const_constraints(const G& cg) {
|
williamr@2
|
185 |
#ifdef BOOST_VECTOR_AS_GRAPH_GRAPH_ADL_HACK
|
williamr@2
|
186 |
// dwa 2003/7/11 -- This clearly shouldn't be necessary, but if
|
williamr@2
|
187 |
// you want to use vector_as_graph, it is! I'm sure the graph
|
williamr@2
|
188 |
// library leaves these out all over the place. Probably a
|
williamr@2
|
189 |
// redesign involving specializing a template with a static
|
williamr@2
|
190 |
// member function is in order :(
|
williamr@2
|
191 |
using boost::vertices;
|
williamr@2
|
192 |
#endif
|
williamr@2
|
193 |
|
williamr@2
|
194 |
p = vertices(cg);
|
williamr@2
|
195 |
v = *p.first;
|
williamr@2
|
196 |
V = num_vertices(cg);
|
williamr@2
|
197 |
}
|
williamr@2
|
198 |
std::pair<vertex_iterator,vertex_iterator> p;
|
williamr@2
|
199 |
typename graph_traits<G>::vertex_descriptor v;
|
williamr@2
|
200 |
G g;
|
williamr@2
|
201 |
vertices_size_type V;
|
williamr@2
|
202 |
};
|
williamr@2
|
203 |
|
williamr@2
|
204 |
template <class G>
|
williamr@2
|
205 |
struct EdgeListGraphConcept
|
williamr@2
|
206 |
{
|
williamr@2
|
207 |
typedef typename graph_traits<G>::edge_descriptor edge_descriptor;
|
williamr@2
|
208 |
typedef typename graph_traits<G>::edge_iterator edge_iterator;
|
williamr@2
|
209 |
typedef typename graph_traits<G>::edges_size_type edges_size_type;
|
williamr@2
|
210 |
typedef typename graph_traits<G>::traversal_category
|
williamr@2
|
211 |
traversal_category;
|
williamr@2
|
212 |
void constraints() {
|
williamr@2
|
213 |
function_requires< GraphConcept<G> >();
|
williamr@2
|
214 |
function_requires< MultiPassInputIteratorConcept<edge_iterator> >();
|
williamr@2
|
215 |
function_requires< DefaultConstructibleConcept<edge_descriptor> >();
|
williamr@2
|
216 |
function_requires< EqualityComparableConcept<edge_descriptor> >();
|
williamr@2
|
217 |
function_requires< AssignableConcept<edge_descriptor> >();
|
williamr@2
|
218 |
function_requires< ConvertibleConcept<traversal_category,
|
williamr@2
|
219 |
edge_list_graph_tag> >();
|
williamr@2
|
220 |
|
williamr@2
|
221 |
p = edges(g);
|
williamr@2
|
222 |
e = *p.first;
|
williamr@2
|
223 |
u = source(e, g);
|
williamr@2
|
224 |
v = target(e, g);
|
williamr@2
|
225 |
const_constraints(g);
|
williamr@2
|
226 |
}
|
williamr@2
|
227 |
void const_constraints(const G& cg) {
|
williamr@2
|
228 |
p = edges(cg);
|
williamr@2
|
229 |
E = num_edges(cg);
|
williamr@2
|
230 |
e = *p.first;
|
williamr@2
|
231 |
u = source(e, cg);
|
williamr@2
|
232 |
v = target(e, cg);
|
williamr@2
|
233 |
}
|
williamr@2
|
234 |
std::pair<edge_iterator,edge_iterator> p;
|
williamr@2
|
235 |
typename graph_traits<G>::vertex_descriptor u, v;
|
williamr@2
|
236 |
typename graph_traits<G>::edge_descriptor e;
|
williamr@2
|
237 |
edges_size_type E;
|
williamr@2
|
238 |
G g;
|
williamr@2
|
239 |
};
|
williamr@2
|
240 |
|
williamr@2
|
241 |
template <class G>
|
williamr@2
|
242 |
struct VertexAndEdgeListGraphConcept
|
williamr@2
|
243 |
{
|
williamr@2
|
244 |
void constraints() {
|
williamr@2
|
245 |
function_requires< VertexListGraphConcept<G> >();
|
williamr@2
|
246 |
function_requires< EdgeListGraphConcept<G> >();
|
williamr@2
|
247 |
}
|
williamr@2
|
248 |
};
|
williamr@2
|
249 |
|
williamr@2
|
250 |
// Where to put the requirement for this constructor?
|
williamr@2
|
251 |
// G g(n_vertices);
|
williamr@2
|
252 |
// Not in mutable graph, then LEDA graph's can't be models of
|
williamr@2
|
253 |
// MutableGraph.
|
williamr@2
|
254 |
|
williamr@2
|
255 |
template <class G>
|
williamr@2
|
256 |
struct EdgeMutableGraphConcept
|
williamr@2
|
257 |
{
|
williamr@2
|
258 |
typedef typename graph_traits<G>::edge_descriptor edge_descriptor;
|
williamr@2
|
259 |
void constraints() {
|
williamr@2
|
260 |
p = add_edge(u, v, g);
|
williamr@2
|
261 |
remove_edge(u, v, g);
|
williamr@2
|
262 |
remove_edge(e, g);
|
williamr@2
|
263 |
clear_vertex(v, g);
|
williamr@2
|
264 |
}
|
williamr@2
|
265 |
G g;
|
williamr@2
|
266 |
edge_descriptor e;
|
williamr@2
|
267 |
std::pair<edge_descriptor, bool> p;
|
williamr@2
|
268 |
typename graph_traits<G>::vertex_descriptor u, v;
|
williamr@2
|
269 |
};
|
williamr@2
|
270 |
|
williamr@2
|
271 |
template <class G>
|
williamr@2
|
272 |
struct VertexMutableGraphConcept
|
williamr@2
|
273 |
{
|
williamr@2
|
274 |
void constraints() {
|
williamr@2
|
275 |
v = add_vertex(g);
|
williamr@2
|
276 |
remove_vertex(v, g);
|
williamr@2
|
277 |
}
|
williamr@2
|
278 |
G g;
|
williamr@2
|
279 |
typename graph_traits<G>::vertex_descriptor u, v;
|
williamr@2
|
280 |
};
|
williamr@2
|
281 |
|
williamr@2
|
282 |
template <class G>
|
williamr@2
|
283 |
struct MutableGraphConcept
|
williamr@2
|
284 |
{
|
williamr@2
|
285 |
void constraints() {
|
williamr@2
|
286 |
function_requires< EdgeMutableGraphConcept<G> >();
|
williamr@2
|
287 |
function_requires< VertexMutableGraphConcept<G> >();
|
williamr@2
|
288 |
}
|
williamr@2
|
289 |
};
|
williamr@2
|
290 |
|
williamr@2
|
291 |
template <class edge_descriptor>
|
williamr@2
|
292 |
struct dummy_edge_predicate {
|
williamr@2
|
293 |
bool operator()(const edge_descriptor&) const {
|
williamr@2
|
294 |
return false;
|
williamr@2
|
295 |
}
|
williamr@2
|
296 |
};
|
williamr@2
|
297 |
|
williamr@2
|
298 |
template <class G>
|
williamr@2
|
299 |
struct MutableIncidenceGraphConcept
|
williamr@2
|
300 |
{
|
williamr@2
|
301 |
void constraints() {
|
williamr@2
|
302 |
function_requires< MutableGraphConcept<G> >();
|
williamr@2
|
303 |
remove_edge(iter, g);
|
williamr@2
|
304 |
remove_out_edge_if(u, p, g);
|
williamr@2
|
305 |
}
|
williamr@2
|
306 |
G g;
|
williamr@2
|
307 |
typedef typename graph_traits<G>::edge_descriptor edge_descriptor;
|
williamr@2
|
308 |
dummy_edge_predicate<edge_descriptor> p;
|
williamr@2
|
309 |
typename boost::graph_traits<G>::vertex_descriptor u;
|
williamr@2
|
310 |
typename boost::graph_traits<G>::out_edge_iterator iter;
|
williamr@2
|
311 |
};
|
williamr@2
|
312 |
|
williamr@2
|
313 |
template <class G>
|
williamr@2
|
314 |
struct MutableBidirectionalGraphConcept
|
williamr@2
|
315 |
{
|
williamr@2
|
316 |
void constraints() {
|
williamr@2
|
317 |
function_requires< MutableIncidenceGraphConcept<G> >();
|
williamr@2
|
318 |
remove_in_edge_if(u, p, g);
|
williamr@2
|
319 |
}
|
williamr@2
|
320 |
G g;
|
williamr@2
|
321 |
typedef typename graph_traits<G>::edge_descriptor edge_descriptor;
|
williamr@2
|
322 |
dummy_edge_predicate<edge_descriptor> p;
|
williamr@2
|
323 |
typename boost::graph_traits<G>::vertex_descriptor u;
|
williamr@2
|
324 |
};
|
williamr@2
|
325 |
|
williamr@2
|
326 |
template <class G>
|
williamr@2
|
327 |
struct MutableEdgeListGraphConcept
|
williamr@2
|
328 |
{
|
williamr@2
|
329 |
void constraints() {
|
williamr@2
|
330 |
function_requires< EdgeMutableGraphConcept<G> >();
|
williamr@2
|
331 |
remove_edge_if(p, g);
|
williamr@2
|
332 |
}
|
williamr@2
|
333 |
G g;
|
williamr@2
|
334 |
typedef typename graph_traits<G>::edge_descriptor edge_descriptor;
|
williamr@2
|
335 |
dummy_edge_predicate<edge_descriptor> p;
|
williamr@2
|
336 |
};
|
williamr@2
|
337 |
|
williamr@2
|
338 |
template <class G>
|
williamr@2
|
339 |
struct VertexMutablePropertyGraphConcept
|
williamr@2
|
340 |
{
|
williamr@2
|
341 |
void constraints() {
|
williamr@2
|
342 |
function_requires< VertexMutableGraphConcept<G> >();
|
williamr@2
|
343 |
v = add_vertex(vp, g);
|
williamr@2
|
344 |
}
|
williamr@2
|
345 |
G g;
|
williamr@2
|
346 |
typename graph_traits<G>::vertex_descriptor v;
|
williamr@2
|
347 |
typename vertex_property<G>::type vp;
|
williamr@2
|
348 |
};
|
williamr@2
|
349 |
|
williamr@2
|
350 |
template <class G>
|
williamr@2
|
351 |
struct EdgeMutablePropertyGraphConcept
|
williamr@2
|
352 |
{
|
williamr@2
|
353 |
typedef typename graph_traits<G>::edge_descriptor edge_descriptor;
|
williamr@2
|
354 |
void constraints() {
|
williamr@2
|
355 |
function_requires< EdgeMutableGraphConcept<G> >();
|
williamr@2
|
356 |
p = add_edge(u, v, ep, g);
|
williamr@2
|
357 |
}
|
williamr@2
|
358 |
G g;
|
williamr@2
|
359 |
std::pair<edge_descriptor, bool> p;
|
williamr@2
|
360 |
typename graph_traits<G>::vertex_descriptor u, v;
|
williamr@2
|
361 |
typename edge_property<G>::type ep;
|
williamr@2
|
362 |
};
|
williamr@2
|
363 |
|
williamr@2
|
364 |
template <class G>
|
williamr@2
|
365 |
struct AdjacencyMatrixConcept
|
williamr@2
|
366 |
{
|
williamr@2
|
367 |
typedef typename graph_traits<G>::edge_descriptor edge_descriptor;
|
williamr@2
|
368 |
void constraints() {
|
williamr@2
|
369 |
function_requires< GraphConcept<G> >();
|
williamr@2
|
370 |
|
williamr@2
|
371 |
p = edge(u, v, g);
|
williamr@2
|
372 |
const_constraints(g);
|
williamr@2
|
373 |
}
|
williamr@2
|
374 |
void const_constraints(const G& cg) {
|
williamr@2
|
375 |
p = edge(u, v, cg);
|
williamr@2
|
376 |
}
|
williamr@2
|
377 |
typename graph_traits<G>::vertex_descriptor u, v;
|
williamr@2
|
378 |
std::pair<edge_descriptor, bool> p;
|
williamr@2
|
379 |
G g;
|
williamr@2
|
380 |
};
|
williamr@2
|
381 |
|
williamr@2
|
382 |
template <class G, class X, class Property>
|
williamr@2
|
383 |
struct ReadablePropertyGraphConcept
|
williamr@2
|
384 |
{
|
williamr@2
|
385 |
typedef typename property_map<G, Property>::const_type const_Map;
|
williamr@2
|
386 |
void constraints() {
|
williamr@2
|
387 |
function_requires< GraphConcept<G> >();
|
williamr@2
|
388 |
function_requires< ReadablePropertyMapConcept<const_Map, X> >();
|
williamr@2
|
389 |
|
williamr@2
|
390 |
const_constraints(g);
|
williamr@2
|
391 |
}
|
williamr@2
|
392 |
void const_constraints(const G& cg) {
|
williamr@2
|
393 |
const_Map pmap = get(Property(), cg);
|
williamr@2
|
394 |
pval = get(Property(), cg, x);
|
williamr@2
|
395 |
ignore_unused_variable_warning(pmap);
|
williamr@2
|
396 |
}
|
williamr@2
|
397 |
G g;
|
williamr@2
|
398 |
X x;
|
williamr@2
|
399 |
typename property_traits<const_Map>::value_type pval;
|
williamr@2
|
400 |
};
|
williamr@2
|
401 |
|
williamr@2
|
402 |
template <class G, class X, class Property>
|
williamr@2
|
403 |
struct PropertyGraphConcept
|
williamr@2
|
404 |
{
|
williamr@2
|
405 |
typedef typename property_map<G, Property>::type Map;
|
williamr@2
|
406 |
void constraints() {
|
williamr@2
|
407 |
function_requires< ReadablePropertyGraphConcept<G, X, Property> >();
|
williamr@2
|
408 |
function_requires< ReadWritePropertyMapConcept<Map, X> >();
|
williamr@2
|
409 |
|
williamr@2
|
410 |
Map pmap = get(Property(), g);
|
williamr@2
|
411 |
pval = get(Property(), g, x);
|
williamr@2
|
412 |
put(Property(), g, x, pval);
|
williamr@2
|
413 |
ignore_unused_variable_warning(pmap);
|
williamr@2
|
414 |
}
|
williamr@2
|
415 |
G g;
|
williamr@2
|
416 |
X x;
|
williamr@2
|
417 |
typename property_traits<Map>::value_type pval;
|
williamr@2
|
418 |
};
|
williamr@2
|
419 |
|
williamr@2
|
420 |
template <class G, class X, class Property>
|
williamr@2
|
421 |
struct LvaluePropertyGraphConcept
|
williamr@2
|
422 |
{
|
williamr@2
|
423 |
typedef typename property_map<G, Property>::type Map;
|
williamr@2
|
424 |
typedef typename property_map<G, Property>::const_type const_Map;
|
williamr@2
|
425 |
void constraints() {
|
williamr@2
|
426 |
function_requires< ReadablePropertyGraphConcept<G, X, Property> >();
|
williamr@2
|
427 |
function_requires< LvaluePropertyMapConcept<const_Map, X> >();
|
williamr@2
|
428 |
|
williamr@2
|
429 |
pval = get(Property(), g, x);
|
williamr@2
|
430 |
put(Property(), g, x, pval);
|
williamr@2
|
431 |
}
|
williamr@2
|
432 |
G g;
|
williamr@2
|
433 |
X x;
|
williamr@2
|
434 |
typename property_traits<Map>::value_type pval;
|
williamr@2
|
435 |
};
|
williamr@2
|
436 |
|
williamr@2
|
437 |
// This needs to move out of the graph library
|
williamr@2
|
438 |
template <class B>
|
williamr@2
|
439 |
struct BufferConcept
|
williamr@2
|
440 |
{
|
williamr@2
|
441 |
void constraints() {
|
williamr@2
|
442 |
b.push(t);
|
williamr@2
|
443 |
b.pop();
|
williamr@2
|
444 |
typename B::value_type& v = b.top();
|
williamr@2
|
445 |
const_constraints(b);
|
williamr@2
|
446 |
ignore_unused_variable_warning(v);
|
williamr@2
|
447 |
}
|
williamr@2
|
448 |
void const_constraints(const B& cb) {
|
williamr@2
|
449 |
const typename B::value_type& v = cb.top();
|
williamr@2
|
450 |
n = cb.size();
|
williamr@2
|
451 |
bool e = cb.empty();
|
williamr@2
|
452 |
ignore_unused_variable_warning(v);
|
williamr@2
|
453 |
ignore_unused_variable_warning(e);
|
williamr@2
|
454 |
}
|
williamr@2
|
455 |
typename B::size_type n;
|
williamr@2
|
456 |
typename B::value_type t;
|
williamr@2
|
457 |
B b;
|
williamr@2
|
458 |
};
|
williamr@2
|
459 |
|
williamr@2
|
460 |
template <class C>
|
williamr@2
|
461 |
struct ColorValueConcept
|
williamr@2
|
462 |
{
|
williamr@2
|
463 |
void constraints() {
|
williamr@2
|
464 |
function_requires< EqualityComparableConcept<C> >();
|
williamr@2
|
465 |
function_requires< DefaultConstructibleConcept<C> >();
|
williamr@2
|
466 |
|
williamr@2
|
467 |
c = color_traits<C>::white();
|
williamr@2
|
468 |
c = color_traits<C>::gray();
|
williamr@2
|
469 |
c = color_traits<C>::black();
|
williamr@2
|
470 |
}
|
williamr@2
|
471 |
C c;
|
williamr@2
|
472 |
};
|
williamr@2
|
473 |
|
williamr@2
|
474 |
template <class M, class I, class V>
|
williamr@2
|
475 |
struct BasicMatrixConcept
|
williamr@2
|
476 |
{
|
williamr@2
|
477 |
void constraints() {
|
williamr@2
|
478 |
V& elt = A[i][j];
|
williamr@2
|
479 |
const_constraints(A);
|
williamr@2
|
480 |
ignore_unused_variable_warning(elt);
|
williamr@2
|
481 |
}
|
williamr@2
|
482 |
void const_constraints(const M& cA) {
|
williamr@2
|
483 |
const V& elt = cA[i][j];
|
williamr@2
|
484 |
ignore_unused_variable_warning(elt);
|
williamr@2
|
485 |
}
|
williamr@2
|
486 |
M A;
|
williamr@2
|
487 |
I i, j;
|
williamr@2
|
488 |
};
|
williamr@2
|
489 |
|
williamr@2
|
490 |
} // namespace boost
|
williamr@2
|
491 |
|
williamr@2
|
492 |
#endif /* BOOST_GRAPH_CONCEPTS_H */
|