Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-29 09:22:58

0001 // (C) Copyright 2007-2009 Andrew Sutton
0002 //
0003 // Use, modification and distribution are subject to the
0004 // Boost Software License, Version 1.0 (See accompanying file
0005 // LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 #ifndef BOOST_GRAPH_DETAIL_INDEX_HPP
0008 #define BOOST_GRAPH_DETAIL_INDEX_HPP
0009 
0010 #include <boost/graph/graph_traits.hpp>
0011 #include <boost/graph/properties.hpp>
0012 
0013 // The structures in this module are responsible for selecting and defining
0014 // types for accessing a builting index map. Note that the selection of these
0015 // types requires the Graph parameter to model either VertexIndexGraph or
0016 // EdgeIndexGraph.
0017 
0018 namespace boost
0019 {
0020 namespace detail
0021 {
0022     template < typename Graph > struct vertex_indexer
0023     {
0024         typedef vertex_index_t index_type;
0025         typedef typename property_map< Graph, vertex_index_t >::type map_type;
0026         typedef typename property_map< Graph, vertex_index_t >::const_type
0027             const_map_type;
0028         typedef typename property_traits< map_type >::value_type value_type;
0029         typedef typename graph_traits< Graph >::vertex_descriptor key_type;
0030 
0031         static const_map_type index_map(const Graph& g)
0032         {
0033             return get(vertex_index, g);
0034         }
0035 
0036         static map_type index_map(Graph& g) { return get(vertex_index, g); }
0037 
0038         static value_type index(key_type k, const Graph& g)
0039         {
0040             return get(vertex_index, g, k);
0041         }
0042     };
0043 
0044     template < typename Graph > struct edge_indexer
0045     {
0046         typedef edge_index_t index_type;
0047         typedef typename property_map< Graph, edge_index_t >::type map_type;
0048         typedef typename property_map< Graph, edge_index_t >::const_type
0049             const_map_type;
0050         typedef typename property_traits< map_type >::value_type value_type;
0051         typedef typename graph_traits< Graph >::edge_descriptor key_type;
0052 
0053         static const_map_type index_map(const Graph& g)
0054         {
0055             return get(edge_index, g);
0056         }
0057 
0058         static map_type index_map(Graph& g) { return get(edge_index, g); }
0059 
0060         static value_type index(key_type k, const Graph& g)
0061         {
0062             return get(edge_index, g, k);
0063         }
0064     };
0065 
0066     // NOTE: The Graph parameter MUST be a model of VertexIndexGraph or
0067     // VertexEdgeGraph - whichever type Key is selecting.
0068     template < typename Graph, typename Key > struct choose_indexer
0069     {
0070         typedef typename mpl::if_<
0071             is_same< Key, typename graph_traits< Graph >::vertex_descriptor >,
0072             vertex_indexer< Graph >, edge_indexer< Graph > >::type indexer_type;
0073         typedef typename indexer_type::index_type index_type;
0074     };
0075 }
0076 }
0077 
0078 #endif