Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:37:10

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 
0012 // The structures in this module are responsible for selecting and defining
0013 // types for accessing a builting index map. Note that the selection of these
0014 // types requires the Graph parameter to model either VertexIndexGraph or
0015 // EdgeIndexGraph.
0016 
0017 namespace boost
0018 {
0019 namespace detail
0020 {
0021     template < typename Graph > struct vertex_indexer
0022     {
0023         typedef vertex_index_t index_type;
0024         typedef typename property_map< Graph, vertex_index_t >::type map_type;
0025         typedef typename property_map< Graph, vertex_index_t >::const_type
0026             const_map_type;
0027         typedef typename property_traits< map_type >::value_type value_type;
0028         typedef typename graph_traits< Graph >::vertex_descriptor key_type;
0029 
0030         static const_map_type index_map(const Graph& g)
0031         {
0032             return get(vertex_index, g);
0033         }
0034 
0035         static map_type index_map(Graph& g) { return get(vertex_index, g); }
0036 
0037         static value_type index(key_type k, const Graph& g)
0038         {
0039             return get(vertex_index, g, k);
0040         }
0041     };
0042 
0043     template < typename Graph > struct edge_indexer
0044     {
0045         typedef edge_index_t index_type;
0046         typedef typename property_map< Graph, edge_index_t >::type map_type;
0047         typedef typename property_map< Graph, edge_index_t >::const_type
0048             const_map_type;
0049         typedef typename property_traits< map_type >::value_type value_type;
0050         typedef typename graph_traits< Graph >::edge_descriptor key_type;
0051 
0052         static const_map_type index_map(const Graph& g)
0053         {
0054             return get(edge_index, g);
0055         }
0056 
0057         static map_type index_map(Graph& g) { return get(edge_index, g); }
0058 
0059         static value_type index(key_type k, const Graph& g)
0060         {
0061             return get(edge_index, g, k);
0062         }
0063     };
0064 
0065     // NOTE: The Graph parameter MUST be a model of VertexIndexGraph or
0066     // VertexEdgeGraph - whichever type Key is selecting.
0067     template < typename Graph, typename Key > struct choose_indexer
0068     {
0069         typedef typename mpl::if_<
0070             is_same< Key, typename graph_traits< Graph >::vertex_descriptor >,
0071             vertex_indexer< Graph >, edge_indexer< Graph > >::type indexer_type;
0072         typedef typename indexer_type::index_type index_type;
0073     };
0074 }
0075 }
0076 
0077 #endif