annotate DEPENDENCIES/generic/include/boost/graph/exterior_property.hpp @ 118:770eb830ec19 emscripten

Typo fix
author Chris Cannam
date Wed, 18 May 2016 16:14:08 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // (C) Copyright 2007-2009 Andrew Sutton
Chris@16 2 //
Chris@16 3 // Use, modification and distribution are subject to the
Chris@16 4 // Boost Software License, Version 1.0 (See accompanying file
Chris@16 5 // LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6
Chris@16 7 #ifndef BOOST_GRAPH_EXTERIOR_PROPERTY_HPP
Chris@16 8 #define BOOST_GRAPH_EXTERIOR_PROPERTY_HPP
Chris@16 9
Chris@16 10 #include <vector>
Chris@16 11 #include <boost/graph/property_maps/container_property_map.hpp>
Chris@16 12 #include <boost/graph/property_maps/matrix_property_map.hpp>
Chris@16 13
Chris@16 14 namespace boost {
Chris@16 15 namespace detail {
Chris@16 16 // The vector matrix provides a little abstraction over vector
Chris@16 17 // types that makes matrices easier to work with. Note that it's
Chris@16 18 // non-copyable, meaning you should be passing it by value.
Chris@16 19 template <typename Value>
Chris@16 20 struct vector_matrix
Chris@16 21 {
Chris@16 22 typedef std::vector<Value> container_type;
Chris@16 23 typedef std::vector<container_type> matrix_type;
Chris@16 24
Chris@16 25 typedef container_type value_type;
Chris@16 26 typedef container_type& reference;
Chris@16 27 typedef const container_type const_reference;
Chris@16 28 typedef container_type* pointer;
Chris@16 29 typedef typename matrix_type::size_type size_type;
Chris@16 30
Chris@16 31 // Instantiate the matrix over n elements (creates an nxn matrix).
Chris@16 32 // The graph has to be passed in order to ensure the index maps
Chris@16 33 // are constructed correctly when returning indexible elements.
Chris@16 34 inline vector_matrix(size_type n)
Chris@16 35 : m_matrix(n, container_type(n))
Chris@16 36 { }
Chris@16 37
Chris@16 38 inline reference operator [](size_type n)
Chris@16 39 { return m_matrix[n]; }
Chris@16 40
Chris@16 41 inline const_reference operator [](size_type n) const
Chris@16 42 { return m_matrix[n]; }
Chris@16 43
Chris@16 44 matrix_type m_matrix;
Chris@16 45 };
Chris@16 46 } /* namespace detail */
Chris@16 47
Chris@16 48 /**
Chris@16 49 * The exterior_property metafunction defines an appropriate set of types for
Chris@16 50 * creating an exterior property. An exterior property is comprised of a both
Chris@16 51 * a container and a property map that acts as its abstraction. An extension
Chris@16 52 * of this metafunction will select an appropriate "matrix" property that
Chris@16 53 * records values for pairs of vertices.
Chris@16 54 *
Chris@16 55 * @todo This does not currently support the ability to define exterior
Chris@16 56 * properties for graph types that do not model the IndexGraph concepts. A
Chris@16 57 * solution should not be especially difficult, but will require an extension
Chris@16 58 * of type traits to affect the type selection.
Chris@16 59 */
Chris@16 60 template <typename Graph, typename Key, typename Value>
Chris@16 61 struct exterior_property
Chris@16 62 {
Chris@16 63 typedef Key key_type;
Chris@16 64 typedef Value value_type;
Chris@16 65
Chris@16 66 typedef std::vector<Value> container_type;
Chris@16 67 typedef container_property_map<Graph, Key, container_type> map_type;
Chris@16 68
Chris@16 69 typedef detail::vector_matrix<Value> matrix_type;
Chris@16 70 typedef matrix_property_map<Graph, Key, matrix_type> matrix_map_type;
Chris@16 71
Chris@16 72 private:
Chris@16 73 exterior_property() { }
Chris@16 74 exterior_property(const exterior_property&) { }
Chris@16 75 };
Chris@16 76
Chris@16 77 /**
Chris@16 78 * Define a the container and property map types requried to create an exterior
Chris@16 79 * vertex property for the given value type. The Graph parameter is required to
Chris@16 80 * model the VertexIndexGraph concept.
Chris@16 81 */
Chris@16 82 template <typename Graph, typename Value>
Chris@16 83 struct exterior_vertex_property
Chris@16 84 {
Chris@16 85 typedef exterior_property<
Chris@16 86 Graph, typename graph_traits<Graph>::vertex_descriptor, Value
Chris@16 87 > property_type;
Chris@16 88 typedef typename property_type::key_type key_type;
Chris@16 89 typedef typename property_type::value_type value_type;
Chris@16 90 typedef typename property_type::container_type container_type;
Chris@16 91 typedef typename property_type::map_type map_type;
Chris@16 92 typedef typename property_type::matrix_type matrix_type;
Chris@16 93 typedef typename property_type::matrix_map_type matrix_map_type;
Chris@16 94 };
Chris@16 95
Chris@16 96 /**
Chris@16 97 * Define a the container and property map types requried to create an exterior
Chris@16 98 * edge property for the given value type. The Graph parameter is required to
Chris@16 99 * model the EdgeIndexGraph concept.
Chris@16 100 */
Chris@16 101 template <typename Graph, typename Value>
Chris@16 102 struct exterior_edge_property
Chris@16 103 {
Chris@16 104 typedef exterior_property<
Chris@16 105 Graph, typename graph_traits<Graph>::edge_descriptor, Value
Chris@16 106 > property_type;
Chris@16 107 typedef typename property_type::key_type key_type;
Chris@16 108 typedef typename property_type::value_type value_type;
Chris@16 109 typedef typename property_type::container_type container_type;
Chris@16 110 typedef typename property_type::map_type map_type;
Chris@16 111 typedef typename property_type::matrix_type matrix_type;
Chris@16 112 typedef typename property_type::matrix_map_type matrix_map_type;
Chris@16 113 };
Chris@16 114
Chris@16 115 } /* namespace boost */
Chris@16 116
Chris@16 117 #endif