]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // (C) Copyright 2007-2009 Andrew Sutton |
2 | // | |
3 | // Use, modification and distribution are subject to the | |
4 | // Boost Software License, Version 1.0 (See accompanying file | |
5 | // LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) | |
6 | ||
7 | #ifndef BOOST_GRAPH_DETAIL_INDEX_HPP | |
8 | #define BOOST_GRAPH_DETAIL_INDEX_HPP | |
9 | ||
10 | #include <boost/graph/graph_traits.hpp> | |
11 | ||
12 | // The structures in this module are responsible for selecting and defining | |
13 | // types for accessing a builting index map. Note that the selection of these | |
14 | // types requires the Graph parameter to model either VertexIndexGraph or | |
15 | // EdgeIndexGraph. | |
16 | ||
17 | namespace boost | |
18 | { | |
f67539c2 TL |
19 | namespace detail |
20 | { | |
21 | template < typename Graph > struct vertex_indexer | |
7c673cae | 22 | { |
f67539c2 TL |
23 | typedef vertex_index_t index_type; |
24 | typedef typename property_map< Graph, vertex_index_t >::type map_type; | |
25 | typedef typename property_map< Graph, vertex_index_t >::const_type | |
26 | const_map_type; | |
27 | typedef typename property_traits< map_type >::value_type value_type; | |
28 | typedef typename graph_traits< Graph >::vertex_descriptor key_type; | |
7c673cae | 29 | |
f67539c2 TL |
30 | static const_map_type index_map(const Graph& g) |
31 | { | |
32 | return get(vertex_index, g); | |
33 | } | |
7c673cae | 34 | |
f67539c2 | 35 | static map_type index_map(Graph& g) { return get(vertex_index, g); } |
7c673cae | 36 | |
f67539c2 | 37 | static value_type index(key_type k, const Graph& g) |
7c673cae | 38 | { |
f67539c2 TL |
39 | return get(vertex_index, g, k); |
40 | } | |
41 | }; | |
7c673cae | 42 | |
f67539c2 TL |
43 | template < typename Graph > struct edge_indexer |
44 | { | |
45 | typedef edge_index_t index_type; | |
46 | typedef typename property_map< Graph, edge_index_t >::type map_type; | |
47 | typedef typename property_map< Graph, edge_index_t >::const_type | |
48 | const_map_type; | |
49 | typedef typename property_traits< map_type >::value_type value_type; | |
50 | typedef typename graph_traits< Graph >::edge_descriptor key_type; | |
7c673cae | 51 | |
f67539c2 TL |
52 | static const_map_type index_map(const Graph& g) |
53 | { | |
54 | return get(edge_index, g); | |
55 | } | |
7c673cae | 56 | |
f67539c2 | 57 | static map_type index_map(Graph& g) { return get(edge_index, g); } |
7c673cae | 58 | |
f67539c2 | 59 | static value_type index(key_type k, const Graph& g) |
7c673cae | 60 | { |
f67539c2 TL |
61 | return get(edge_index, g, k); |
62 | } | |
63 | }; | |
64 | ||
65 | // NOTE: The Graph parameter MUST be a model of VertexIndexGraph or | |
66 | // VertexEdgeGraph - whichever type Key is selecting. | |
67 | template < typename Graph, typename Key > struct choose_indexer | |
68 | { | |
69 | typedef typename mpl::if_< | |
70 | is_same< Key, typename graph_traits< Graph >::vertex_descriptor >, | |
71 | vertex_indexer< Graph >, edge_indexer< Graph > >::type indexer_type; | |
72 | typedef typename indexer_type::index_type index_type; | |
73 | }; | |
74 | } | |
7c673cae FG |
75 | } |
76 | ||
77 | #endif |