]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | //======================================================================= |
2 | // Copyright 1997-2001 University of Notre Dame. | |
3 | // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek | |
4 | // | |
5 | // Distributed under the Boost Software License, Version 1.0. (See | |
6 | // accompanying file LICENSE_1_0.txt or copy at | |
7 | // http://www.boost.org/LICENSE_1_0.txt) | |
8 | //======================================================================= | |
9 | #ifndef BOOST_GRAPH_SGB_GRAPH_HPP | |
10 | #define BOOST_GRAPH_SGB_GRAPH_HPP | |
11 | ||
12 | #include <boost/config.hpp> | |
7c673cae FG |
13 | #include <boost/operators.hpp> |
14 | #include <boost/property_map/property_map.hpp> | |
15 | #include <boost/graph/graph_traits.hpp> | |
16 | #include <boost/graph/properties.hpp> | |
17 | ||
18 | // Thanks to Andreas Scherer for numerous suggestions and fixes! | |
19 | ||
20 | // This file adapts a Stanford GraphBase (SGB) Graph pointer into a | |
21 | // VertexListGraph. Note that a graph adaptor class is not needed, | |
22 | // SGB's Graph* is used as is. The VertexListGraph concept is fulfilled by | |
23 | // defining the appropriate non-member functions for Graph*. | |
24 | // | |
25 | // The PROTOTYPES change file extensions to SGB must be applied so | |
26 | // that the SGB functions have real prototypes which are necessary for | |
27 | // the C++ compiler. To apply the PROTOTYPES extensions, before you do | |
28 | // "make tests install" for SGB do "ln -s PROTOTYPES/* ." to the SGB | |
29 | // root directory (or just copy all the files from the PROTOTYPES | |
30 | // directory to the SGB root directory). | |
31 | // | |
32 | extern "C" { | |
33 | // We include all global definitions for the general stuff | |
34 | // of The Stanford GraphBase and its various graph generator | |
35 | // functions by reading all SGB headerfiles as in section 2 of | |
36 | // the "test_sample" program. | |
37 | #include <gb_graph.h> /* SGB data structures */ | |
38 | #include <gb_io.h> /* SGB input/output routines */ | |
39 | #include <gb_flip.h> /* random number generator */ | |
40 | #include <gb_dijk.h> /* routines for shortest paths */ | |
41 | #include <gb_basic.h> /* the basic graph operations */ | |
42 | #undef empty /* avoid name clash with C++ standard library */ | |
43 | inline Graph* empty( long n ) /* and provide workaround */ | |
44 | { return board(n,0L,0L,0L,2L,0L,0L); } | |
45 | #include <gb_books.h> /* graphs based on literature */ | |
46 | #include <gb_econ.h> /* graphs based on economic data */ | |
47 | #include <gb_games.h> /* graphs based on football scores */ | |
92f5a8d4 TL |
48 | #undef ap /* avoid name clash with BGL parameter */ |
49 | // ap ==> Vertex::u.I | |
7c673cae FG |
50 | #include <gb_gates.h> /* graphs based on logic circuits */ |
51 | #undef val /* avoid name clash with g++ headerfile stl_tempbuf.h */ | |
52 | // val ==> Vertex::x.I | |
53 | #include <gb_lisa.h> /* graphs based on Mona Lisa */ | |
54 | #include <gb_miles.h> /* graphs based on mileage data */ | |
55 | #include <gb_plane.h> /* planar graphs */ | |
56 | #include <gb_raman.h> /* Ramanujan graphs */ | |
57 | #include <gb_rand.h> /* random graphs */ | |
58 | #include <gb_roget.h> /* graphs based on Roget's Thesaurus */ | |
59 | #include <gb_save.h> /* we save results in ASCII format */ | |
60 | #include <gb_words.h> /* five-letter-word graphs */ | |
61 | #undef weight /* avoid name clash with BGL parameter */ | |
62 | // weight ==> Vertex::u.I | |
63 | } | |
64 | ||
65 | namespace boost { | |
66 | class sgb_edge; | |
67 | } | |
68 | ||
69 | class sgb_out_edge_iterator; | |
70 | class sgb_adj_iterator; | |
71 | class sgb_vertex_iterator; | |
72 | ||
73 | namespace boost { | |
74 | typedef Graph* sgb_graph_ptr; | |
75 | typedef const Graph* sgb_const_graph_ptr; | |
76 | ||
77 | struct sgb_traversal_tag : | |
78 | public virtual vertex_list_graph_tag, | |
79 | public virtual incidence_graph_tag, | |
80 | public virtual adjacency_graph_tag { }; | |
81 | ||
82 | template <> struct graph_traits<sgb_graph_ptr> { | |
83 | typedef Vertex* vertex_descriptor; | |
84 | typedef boost::sgb_edge edge_descriptor; | |
85 | typedef sgb_out_edge_iterator out_edge_iterator; | |
86 | typedef void in_edge_iterator; | |
87 | typedef sgb_adj_iterator adjacency_iterator; | |
88 | typedef sgb_vertex_iterator vertex_iterator; | |
89 | typedef void edge_iterator; | |
90 | typedef long vertices_size_type; | |
91 | typedef long edge_size_type; | |
92 | typedef long degree_size_type; | |
93 | typedef directed_tag directed_category; | |
94 | typedef sgb_traversal_tag traversal_category; | |
95 | typedef allow_parallel_edge_tag edge_parallel_category; | |
92f5a8d4 TL |
96 | /** Return a null descriptor */ |
97 | static vertex_descriptor null_vertex() | |
98 | { return NULL; } | |
7c673cae FG |
99 | }; |
100 | template <> struct graph_traits<sgb_const_graph_ptr> { | |
101 | typedef Vertex* vertex_descriptor; | |
102 | typedef boost::sgb_edge edge_descriptor; | |
103 | typedef sgb_out_edge_iterator out_edge_iterator; | |
104 | typedef void in_edge_iterator; | |
105 | typedef sgb_adj_iterator adjacency_iterator; | |
106 | typedef sgb_vertex_iterator vertex_iterator; | |
107 | typedef void edge_iterator; | |
108 | typedef long vertices_size_type; | |
109 | typedef long edge_size_type; | |
110 | typedef long degree_size_type; | |
111 | typedef directed_tag directed_category; | |
112 | typedef sgb_traversal_tag traversal_category; | |
113 | typedef allow_parallel_edge_tag edge_parallel_category; | |
92f5a8d4 TL |
114 | /** Return a null descriptor */ |
115 | static vertex_descriptor null_vertex() | |
116 | { return NULL; } | |
7c673cae FG |
117 | }; |
118 | } | |
119 | ||
120 | namespace boost { | |
121 | ||
122 | struct edge_length_t { | |
123 | typedef edge_property_tag kind; | |
124 | }; | |
125 | ||
126 | // We could just use Arc* as the edge descriptor type, but | |
127 | // we want to add the source(e,g) function which requires | |
128 | // that we carry along a pointer to the source vertex. | |
129 | class sgb_edge { | |
130 | typedef sgb_edge self; | |
131 | public: | |
132 | sgb_edge() : _arc(0), _src(0) { } | |
133 | sgb_edge(Arc* a, Vertex* s) : _arc(a), _src(s) { } | |
134 | friend Vertex* source(self e, sgb_const_graph_ptr) { return e._src; } | |
135 | friend Vertex* target(self e, sgb_const_graph_ptr) { return e._arc->tip; } | |
136 | friend bool operator==(const self& a, const self& b) { | |
137 | return a._arc == b._arc; } | |
138 | friend bool operator!=(const self& a, const self& b) { | |
139 | return a._arc != b._arc; } | |
140 | #if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) | |
141 | template <class Ref> friend class sgb_edge_length_map; | |
142 | template <class Tag, class Ref> friend class sgb_edge_util_map; | |
143 | friend long get(edge_length_t, const sgb_graph_ptr&, const sgb_edge& key); | |
144 | friend long get(edge_length_t, const sgb_const_graph_ptr&, const sgb_edge& key); | |
145 | friend void put(edge_length_t, sgb_graph_ptr&, const sgb_edge& key, long value); | |
146 | protected: | |
147 | #endif | |
148 | Arc* _arc; | |
149 | Vertex* _src; | |
150 | }; | |
151 | } // namespace boost | |
152 | ||
153 | class sgb_out_edge_iterator | |
154 | : public boost::forward_iterator_helper< | |
155 | sgb_out_edge_iterator, boost::sgb_edge, | |
156 | std::ptrdiff_t, boost::sgb_edge*, boost::sgb_edge> | |
157 | { | |
158 | typedef sgb_out_edge_iterator self; | |
159 | public: | |
160 | sgb_out_edge_iterator() : _src(0), _arc(0) {} | |
161 | sgb_out_edge_iterator(Vertex* s, Arc* d) : _src(s), _arc(d) {} | |
162 | boost::sgb_edge operator*() { return boost::sgb_edge(_arc, _src); } | |
163 | self& operator++() { _arc = _arc->next; return *this; } | |
164 | friend bool operator==(const self& x, const self& y) { | |
165 | return x._arc == y._arc; } | |
166 | protected: | |
167 | Vertex* _src; | |
168 | Arc* _arc; | |
169 | }; | |
170 | ||
171 | class sgb_adj_iterator | |
172 | : public boost::forward_iterator_helper< | |
173 | sgb_adj_iterator, Vertex*, std::ptrdiff_t, Vertex**,Vertex*> | |
174 | { | |
175 | typedef sgb_adj_iterator self; | |
176 | public: | |
177 | sgb_adj_iterator() : _arc(0) {} | |
178 | sgb_adj_iterator(Arc* d) : _arc(d) {} | |
179 | Vertex* operator*() { return _arc->tip; } | |
180 | self& operator++() { _arc = _arc->next; return *this; } | |
181 | friend bool operator==(const self& x, const self& y) { | |
182 | return x._arc == y._arc; } | |
183 | protected: | |
184 | Arc* _arc; | |
185 | }; | |
186 | ||
187 | // The reason we have this instead of just using Vertex* is that we | |
188 | // want to use Vertex* as the vertex_descriptor instead of just | |
189 | // Vertex, which avoids problems with boost passing vertex descriptors | |
190 | // by value and how that interacts with the sgb_vertex_id_map. | |
191 | class sgb_vertex_iterator | |
192 | : public boost::forward_iterator_helper< | |
193 | sgb_vertex_iterator, Vertex*, std::ptrdiff_t, Vertex**, Vertex*> | |
194 | { | |
195 | typedef sgb_vertex_iterator self; | |
196 | public: | |
197 | sgb_vertex_iterator() : _v(0) { } | |
198 | sgb_vertex_iterator(Vertex* v) : _v(v) { } | |
199 | Vertex* operator*() { return _v; } | |
200 | self& operator++() { ++_v; return *this; } | |
201 | friend bool operator==(const self& x, const self& y) { | |
202 | return x._v == y._v; } | |
203 | protected: | |
204 | Vertex* _v; | |
205 | }; | |
206 | ||
207 | namespace boost { | |
208 | ||
209 | inline std::pair<sgb_vertex_iterator,sgb_vertex_iterator> | |
210 | vertices(sgb_const_graph_ptr g) | |
211 | { | |
212 | return std::make_pair(sgb_vertex_iterator(g->vertices), | |
213 | sgb_vertex_iterator(g->vertices + g->n)); | |
214 | } | |
215 | ||
216 | inline std::pair<sgb_out_edge_iterator,sgb_out_edge_iterator> | |
217 | out_edges(Vertex* u, sgb_const_graph_ptr) | |
218 | { | |
219 | return std::make_pair( sgb_out_edge_iterator(u, u->arcs), | |
220 | sgb_out_edge_iterator(u, 0) ); | |
221 | } | |
222 | ||
223 | inline boost::graph_traits<sgb_graph_ptr>::degree_size_type | |
224 | out_degree(Vertex* u, sgb_const_graph_ptr g) | |
225 | { | |
226 | boost::graph_traits<sgb_graph_ptr>::out_edge_iterator i, i_end; | |
227 | boost::tie(i, i_end) = out_edges(u, g); | |
228 | return std::distance(i, i_end); | |
229 | } | |
230 | ||
231 | // in_edges? | |
232 | ||
233 | inline std::pair<sgb_adj_iterator,sgb_adj_iterator> | |
234 | adjacent_vertices(Vertex* u, sgb_const_graph_ptr) | |
235 | { | |
236 | return std::make_pair( sgb_adj_iterator(u->arcs), | |
237 | sgb_adj_iterator(0) ); | |
238 | } | |
239 | ||
240 | inline long num_vertices(sgb_const_graph_ptr g) { return g->n; } | |
241 | inline long num_edges(sgb_const_graph_ptr g) { return g->m; } | |
242 | ||
243 | inline Vertex* vertex(long v, sgb_const_graph_ptr g) | |
244 | { return g->vertices + v; } | |
245 | ||
246 | // Various Property Maps | |
247 | ||
248 | // Vertex ID | |
249 | class sgb_vertex_id_map | |
250 | : public boost::put_get_helper<long, sgb_vertex_id_map> | |
251 | { | |
252 | public: | |
253 | typedef boost::readable_property_map_tag category; | |
254 | typedef long value_type; | |
255 | typedef long reference; | |
256 | typedef Vertex* key_type; | |
257 | sgb_vertex_id_map() : _g(0) { } | |
258 | sgb_vertex_id_map(sgb_graph_ptr g) : _g(g) { } | |
259 | long operator[](Vertex* v) const { return v - _g->vertices; } | |
260 | protected: | |
261 | sgb_graph_ptr _g; | |
262 | }; | |
263 | inline sgb_vertex_id_map get(vertex_index_t, sgb_graph_ptr g) { | |
264 | return sgb_vertex_id_map(g); | |
265 | } | |
266 | ||
267 | // Vertex Name | |
268 | class sgb_vertex_name_map | |
269 | : public boost::put_get_helper<char*, sgb_vertex_name_map> | |
270 | { | |
271 | public: | |
272 | typedef boost::readable_property_map_tag category; | |
273 | typedef char* value_type; | |
274 | typedef char* reference; | |
275 | typedef Vertex* key_type; | |
276 | char* operator[](Vertex* v) const { return v->name; } | |
277 | }; | |
278 | inline sgb_vertex_name_map get(vertex_name_t, sgb_graph_ptr) { | |
279 | return sgb_vertex_name_map(); | |
280 | } | |
281 | ||
282 | // Vertex Property Tags | |
283 | #define SGB_PROPERTY_TAG(KIND,TAG) \ | |
284 | template <class T> struct TAG##_property { \ | |
285 | typedef KIND##_property_tag kind; \ | |
286 | typedef T type; \ | |
287 | }; | |
288 | SGB_PROPERTY_TAG(vertex, u) | |
289 | SGB_PROPERTY_TAG(vertex, v) | |
290 | SGB_PROPERTY_TAG(vertex, w) | |
291 | SGB_PROPERTY_TAG(vertex, x) | |
292 | SGB_PROPERTY_TAG(vertex, y) | |
293 | SGB_PROPERTY_TAG(vertex, z) | |
294 | ||
295 | // Edge Property Tags | |
296 | SGB_PROPERTY_TAG(edge, a) | |
297 | SGB_PROPERTY_TAG(edge, b) | |
298 | ||
299 | // Various Utility Maps | |
300 | ||
301 | // helpers | |
302 | inline Vertex*& get_util(util& u, Vertex*) { return u.V; } | |
303 | inline Arc*& get_util(util& u, Arc*) { return u.A; } | |
304 | inline sgb_graph_ptr& get_util(util& u, sgb_graph_ptr) { return u.G; } | |
305 | inline char*& get_util(util& u, char*) { return u.S; } | |
306 | inline long& get_util(util& u, long) { return u.I; } | |
307 | ||
308 | #define SGB_GET_UTIL_FIELD(KIND,X) \ | |
309 | template <class T> \ | |
310 | inline T& get_util_field(KIND* k, X##_property<T>) { \ | |
311 | return get_util(k->X, T()); } | |
312 | ||
313 | SGB_GET_UTIL_FIELD(Vertex, u) | |
314 | SGB_GET_UTIL_FIELD(Vertex, v) | |
315 | SGB_GET_UTIL_FIELD(Vertex, w) | |
316 | SGB_GET_UTIL_FIELD(Vertex, x) | |
317 | SGB_GET_UTIL_FIELD(Vertex, y) | |
318 | SGB_GET_UTIL_FIELD(Vertex, z) | |
319 | ||
320 | SGB_GET_UTIL_FIELD(Arc, a) | |
321 | SGB_GET_UTIL_FIELD(Arc, b) | |
322 | ||
323 | // Vertex Utility Map | |
324 | template <class Tag, class Ref> | |
325 | class sgb_vertex_util_map | |
326 | : public boost::put_get_helper<Ref, sgb_vertex_util_map<Tag, Ref> > | |
327 | { | |
328 | Tag tag; | |
329 | public: | |
330 | explicit sgb_vertex_util_map(Tag tag = Tag()): tag(tag) {} | |
331 | typedef boost::lvalue_property_map_tag category; | |
332 | typedef typename Tag::type value_type; | |
333 | typedef Vertex* key_type; | |
334 | typedef Ref reference; | |
335 | reference operator[](Vertex* v) const { | |
336 | return get_util_field(v, tag); | |
337 | } | |
338 | }; | |
339 | ||
340 | // Edge Utility Map | |
341 | template <class Tag, class Ref> | |
342 | class sgb_edge_util_map | |
343 | : public boost::put_get_helper<Ref, sgb_edge_util_map<Tag, Ref> > | |
344 | { | |
345 | Tag tag; | |
346 | public: | |
347 | explicit sgb_edge_util_map(Tag tag = Tag()): tag(tag) {} | |
348 | typedef boost::lvalue_property_map_tag category; | |
349 | typedef typename Tag::type value_type; | |
350 | typedef Vertex* key_type; | |
351 | typedef Ref reference; | |
352 | reference operator[](const sgb_edge& e) const { | |
353 | return get_util_field(e._arc, tag); | |
354 | } | |
355 | }; | |
356 | ||
357 | ||
358 | template <class Tag> | |
359 | inline sgb_vertex_util_map<Tag, const typename Tag::type&> | |
360 | get_property_map(Tag, const sgb_graph_ptr& g, vertex_property_tag) { | |
361 | return sgb_vertex_util_map<Tag, const typename Tag::type&>(); | |
362 | } | |
363 | template <class Tag> | |
364 | inline sgb_vertex_util_map<Tag, typename Tag::type&> | |
365 | get_property_map(Tag, sgb_graph_ptr& g, vertex_property_tag) { | |
366 | return sgb_vertex_util_map<Tag, typename Tag::type&>(); | |
367 | } | |
368 | ||
369 | template <class Tag> | |
370 | inline sgb_edge_util_map<Tag, const typename Tag::type&> | |
371 | get_property_map(Tag, const sgb_graph_ptr& g, edge_property_tag) { | |
372 | return sgb_edge_util_map<Tag, const typename Tag::type&>(); | |
373 | } | |
374 | template <class Tag> | |
375 | inline sgb_edge_util_map<Tag, typename Tag::type&> | |
376 | get_property_map(Tag, sgb_graph_ptr& g, edge_property_tag) { | |
377 | return sgb_edge_util_map<Tag, typename Tag::type&>(); | |
378 | } | |
379 | ||
380 | ||
381 | // Edge Length Access | |
382 | template <class Ref> | |
383 | class sgb_edge_length_map | |
384 | : public boost::put_get_helper<Ref, sgb_edge_length_map<Ref> > | |
385 | { | |
386 | public: | |
387 | typedef boost::lvalue_property_map_tag category; | |
388 | typedef long value_type; | |
389 | typedef sgb_edge key_type; | |
390 | typedef Ref reference; | |
391 | reference operator[](const sgb_edge& e) const { | |
392 | return e._arc->len; | |
393 | } | |
394 | }; | |
395 | ||
396 | inline sgb_edge_length_map<const long&> | |
397 | get(edge_length_t, const sgb_graph_ptr&) { | |
398 | return sgb_edge_length_map<const long&>(); | |
399 | } | |
400 | inline sgb_edge_length_map<const long&> | |
401 | get(edge_length_t, const sgb_const_graph_ptr&) { | |
402 | return sgb_edge_length_map<const long&>(); | |
403 | } | |
404 | inline sgb_edge_length_map<long&> | |
405 | get(edge_length_t, sgb_graph_ptr&) { | |
406 | return sgb_edge_length_map<long&>(); | |
407 | } | |
408 | inline long | |
409 | get(edge_length_t, const sgb_graph_ptr&, const sgb_edge& key) { | |
410 | return key._arc->len; | |
411 | } | |
412 | inline long | |
413 | get(edge_length_t, const sgb_const_graph_ptr&, const sgb_edge& key) { | |
414 | return key._arc->len; | |
415 | } | |
416 | inline void | |
417 | put(edge_length_t, sgb_graph_ptr&, const sgb_edge& key, long value) | |
418 | { | |
419 | key._arc->len = value; | |
420 | } | |
421 | ||
422 | // Property Map Traits Classes | |
423 | template <> | |
424 | struct property_map<sgb_graph_ptr, edge_length_t> { | |
425 | typedef sgb_edge_length_map<long&> type; | |
426 | typedef sgb_edge_length_map<const long&> const_type; | |
427 | }; | |
428 | template <> | |
429 | struct property_map<sgb_graph_ptr, vertex_index_t> { | |
430 | typedef sgb_vertex_id_map type; | |
431 | typedef sgb_vertex_id_map const_type; | |
432 | }; | |
433 | template <> | |
434 | struct property_map<sgb_graph_ptr, vertex_name_t> { | |
435 | typedef sgb_vertex_name_map type; | |
436 | typedef sgb_vertex_name_map const_type; | |
437 | }; | |
438 | ||
439 | template <> | |
440 | struct property_map<sgb_const_graph_ptr, edge_length_t> { | |
441 | typedef sgb_edge_length_map<const long&> const_type; | |
442 | }; | |
443 | template <> | |
444 | struct property_map<sgb_const_graph_ptr, vertex_index_t> { | |
445 | typedef sgb_vertex_id_map const_type; | |
446 | }; | |
447 | template <> | |
448 | struct property_map<sgb_const_graph_ptr, vertex_name_t> { | |
449 | typedef sgb_vertex_name_map const_type; | |
450 | }; | |
451 | ||
452 | ||
453 | namespace detail { | |
454 | template <class Kind, class PropertyTag> | |
455 | struct sgb_choose_property_map { }; | |
456 | template <class PropertyTag> | |
457 | struct sgb_choose_property_map<vertex_property_tag, PropertyTag> { | |
458 | typedef typename PropertyTag::type value_type; | |
459 | typedef sgb_vertex_util_map<PropertyTag, value_type&> type; | |
460 | typedef sgb_vertex_util_map<PropertyTag, const value_type&> const_type; | |
461 | }; | |
462 | template <class PropertyTag> | |
463 | struct sgb_choose_property_map<edge_property_tag, PropertyTag> { | |
464 | typedef typename PropertyTag::type value_type; | |
465 | typedef sgb_edge_util_map<PropertyTag, value_type&> type; | |
466 | typedef sgb_edge_util_map<PropertyTag, const value_type&> const_type; | |
467 | }; | |
468 | } // namespace detail | |
469 | template <class PropertyTag> | |
470 | struct property_map<sgb_graph_ptr, PropertyTag> { | |
471 | typedef typename property_kind<PropertyTag>::type Kind; | |
472 | typedef detail::sgb_choose_property_map<Kind, PropertyTag> Choice; | |
473 | typedef typename Choice::type type; | |
474 | typedef typename Choice::const_type const_type; | |
475 | }; | |
476 | template <class PropertyTag> | |
477 | struct property_map<sgb_const_graph_ptr, PropertyTag> { | |
478 | typedef typename property_kind<PropertyTag>::type Kind; | |
479 | typedef detail::sgb_choose_property_map<Kind, PropertyTag> Choice; | |
480 | typedef typename Choice::const_type const_type; | |
481 | }; | |
482 | ||
483 | #define SGB_UTIL_ACCESSOR(KIND,X) \ | |
484 | template <class T> \ | |
485 | inline sgb_##KIND##_util_map< X##_property<T>, T&> \ | |
486 | get(X##_property<T>, sgb_graph_ptr&) { \ | |
487 | return sgb_##KIND##_util_map< X##_property<T>, T&>(); \ | |
488 | } \ | |
489 | template <class T> \ | |
490 | inline sgb_##KIND##_util_map< X##_property<T>, const T&> \ | |
491 | get(X##_property<T>, const sgb_graph_ptr&) { \ | |
492 | return sgb_##KIND##_util_map< X##_property<T>, const T&>(); \ | |
493 | } \ | |
494 | template <class T> \ | |
495 | inline sgb_##KIND##_util_map< X##_property<T>, const T&> \ | |
496 | get(X##_property<T>, const sgb_const_graph_ptr&) { \ | |
497 | return sgb_##KIND##_util_map< X##_property<T>, const T&>(); \ | |
498 | } \ | |
499 | template <class T, class Key> \ | |
500 | inline typename \ | |
501 | sgb_##KIND##_util_map< X##_property<T>, const T&>::value_type \ | |
502 | get(X##_property<T>, const sgb_graph_ptr&, const Key& key) { \ | |
503 | return sgb_##KIND##_util_map< X##_property<T>, const T&>()[key]; \ | |
504 | } \ | |
505 | template <class T, class Key> \ | |
506 | inline typename \ | |
507 | sgb_##KIND##_util_map< X##_property<T>, const T&>::value_type \ | |
508 | get(X##_property<T>, const sgb_const_graph_ptr&, const Key& key) { \ | |
509 | return sgb_##KIND##_util_map< X##_property<T>, const T&>()[key]; \ | |
510 | } \ | |
511 | template <class T, class Key, class Value> \ | |
512 | inline void \ | |
513 | put(X##_property<T>, sgb_graph_ptr&, const Key& key, const Value& value) { \ | |
514 | sgb_##KIND##_util_map< X##_property<T>, T&>()[key] = value; \ | |
515 | } | |
516 | ||
517 | ||
518 | SGB_UTIL_ACCESSOR(vertex, u) | |
519 | SGB_UTIL_ACCESSOR(vertex, v) | |
520 | SGB_UTIL_ACCESSOR(vertex, w) | |
521 | SGB_UTIL_ACCESSOR(vertex, x) | |
522 | SGB_UTIL_ACCESSOR(vertex, y) | |
523 | SGB_UTIL_ACCESSOR(vertex, z) | |
524 | ||
525 | SGB_UTIL_ACCESSOR(edge, a) | |
526 | SGB_UTIL_ACCESSOR(edge, b) | |
527 | ||
528 | } // namespace boost | |
529 | ||
530 | #endif // BOOST_GRAPH_SGB_GRAPH_HPP |