File indexing completed on 2025-01-18 09:37:21
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_GRAPH_MATRIX_PROPERTY_MAP_HPP
0008 #define BOOST_GRAPH_MATRIX_PROPERTY_MAP_HPP
0009
0010 #include <boost/graph/property_maps/container_property_map.hpp>
0011
0012 namespace boost
0013 {
0014
0015
0016
0017
0018 template < typename Graph, typename Key, typename Matrix >
0019 struct matrix_property_map
0020 : boost::put_get_helper<
0021 container_property_map< Graph, Key, typename Matrix::value_type >,
0022 matrix_property_map< Graph, Key, Matrix > >
0023 {
0024
0025 typedef typename detail::choose_indexer< Graph, Key >::indexer_type
0026 indexer_type;
0027
0028
0029 typedef typename Matrix::value_type container_type;
0030 typedef container_property_map< Graph, Key, container_type > map_type;
0031
0032 typedef Key key_type;
0033
0034
0035
0036
0037
0038
0039 typedef map_type value_type;
0040 typedef map_type reference;
0041 typedef readable_property_map_tag category;
0042
0043 matrix_property_map() : m_matrix(0), m_graph(0) {}
0044
0045 matrix_property_map(Matrix& m, const Graph& g)
0046 : m_matrix(&m), m_graph(const_cast< Graph* >(&g))
0047 {
0048 }
0049
0050 matrix_property_map(const matrix_property_map& x)
0051 : m_matrix(x.m_matrix), m_graph(x.m_graph)
0052 {
0053 }
0054
0055 inline reference operator[](key_type k) const
0056 {
0057 typedef typename indexer_type::value_type Index;
0058 Index x = indexer_type::index(k, *m_graph);
0059 return map_type((*m_matrix)[x], *m_graph);
0060 }
0061
0062 private:
0063 mutable Matrix* m_matrix;
0064 mutable Graph* m_graph;
0065 };
0066 }
0067
0068 #endif