Boost logo

Boost-Commit :

From: asutton_at_[hidden]
Date: 2007-08-11 11:46:09


Author: asutton
Date: 2007-08-11 11:46:09 EDT (Sat, 11 Aug 2007)
New Revision: 38599
URL: http://svn.boost.org/trac/boost/changeset/38599

Log:
Moved index decisions to details

Added:
   sandbox/SOC/2007/graphs/boost/graph/detail/index.hpp (contents, props changed)
Text files modified:
   sandbox/SOC/2007/graphs/boost/graph/detail/geodesic.hpp | 29 ++++++++++++++++++++---------
   1 files changed, 20 insertions(+), 9 deletions(-)

Modified: sandbox/SOC/2007/graphs/boost/graph/detail/geodesic.hpp
==============================================================================
--- sandbox/SOC/2007/graphs/boost/graph/detail/geodesic.hpp (original)
+++ sandbox/SOC/2007/graphs/boost/graph/detail/geodesic.hpp 2007-08-11 11:46:09 EDT (Sat, 11 Aug 2007)
@@ -8,6 +8,7 @@
 #define BOOST_GRAPH_DETAIL_GEODESIC_HPP
 
 #include <functional>
+#include <boost/graph/new_graph_concepts.hpp>
 #include <boost/graph/numeric_values.hpp>
 
 namespace boost
@@ -23,7 +24,6 @@
     // citeulike-article-id = {1144245},
     // doi = {10.1016/j.socnet.2005.11.005},
     // journal = {Social Networks},
- // keywords = {2006 centrality complex_network graph-theory social sociality social_network},
     // month = {October},
     // number = {4},
     // pages = {466--484},
@@ -43,20 +43,28 @@
         template <typename Graph,
                   typename DistanceMap,
                   typename Combinator,
- typename DistanceNumbers>
- inline typename DistanceNumbers::value_type
+ typename Distance>
+ inline Distance
         combine_distances(const Graph& g,
                           DistanceMap dist,
                           Combinator combine,
- DistanceNumbers distnum)
+ Distance init)
         {
+ function_requires< VertexListGraphConcept<Graph> >();
+ typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
+ typedef typename graph_traits<Graph>::vertex_iterator VertexIterator;
+ function_requires< ReadablePropertyMapConcept<DistanceMap,Vertex> >();
+ function_requires< NumericValueConcept<Distance> >();
+ typedef numeric_values<Distance> DistanceNumbers;
+ function_requires< AdaptableBinaryFunction<Combinator,Distance,Distance,Distance> >();
+
             // If there's ever an infinite distance, then we simply
             // return infinity.
- typename DistanceNumbers::value_type ret(DistanceNumbers::zero());
- typename graph_traits<Graph>::vertex_iterator i, end;
+ Distance ret = init;
+ VertexIterator i, end;
             for(tie(i, end) = vertices(g); i != end; ++i) {
- if(dist[*i] != DistanceNumbers::infinity()) {
- ret = combine(ret, dist[*i]);
+ if(get(dist, *i) != DistanceNumbers::infinity()) {
+ ret = combine(ret, get(dist, *i));
                 }
                 else {
                     ret = DistanceNumbers::infinity();
@@ -81,8 +89,11 @@
         // types, but should be specialized for those types that have
         // discrete notions of reciprocals.
         template <typename T>
- struct reciprocal : public std::unary_function<T, T>
+ struct reciprocal : public std::unary_function<T, T>
         {
+ typedef std::unary_function<T, T> function_type;
+ typedef typename function_type::result_type result_type;
+ typedef typename function_type::argument_type argument_type;
             T operator ()(T t)
             { return T(1) / t; }
         };

Added: sandbox/SOC/2007/graphs/boost/graph/detail/index.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/graphs/boost/graph/detail/index.hpp 2007-08-11 11:46:09 EDT (Sat, 11 Aug 2007)
@@ -0,0 +1,67 @@
+// (C) Copyright Andrew Sutton 2007
+//
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0 (See accompanying file
+// LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GRAPH_DETAIL_INDEX_HXX
+#define BOOST_GRAPH_DETAIL_INDEX_HXX
+
+#include <boost/graph/graph_traits.hpp>
+
+namespace boost
+{
+ namespace detail
+ {
+ template <typename Graph>
+ struct vertex_indexer
+ {
+ typedef vertex_index_t index_type;
+ typedef typename property_map<Graph, vertex_index_t>::type map_type;
+ typedef typename property_map<Graph, vertex_index_t>::const_type const_map_type;
+ typedef typename property_traits<map_type>::value_type value_type;
+ typedef typename graph_traits<Graph>::vertex_descriptor key_type;
+
+ static const_map_type index_map(const Graph& g)
+ { return get(vertex_index, g); }
+
+ static map_type index_map(Graph& g)
+ { return get(vertex_index, g); }
+
+ static value_type index(key_type k, const Graph& g)
+ { return get(vertex_index, g, k); }
+ };
+
+ template <typename Graph>
+ struct edge_indexer
+ {
+ typedef edge_index_t index_type;
+ typedef typename property_map<Graph, edge_index_t>::type map_type;
+ typedef typename property_map<Graph, edge_index_t>::const_type const_map_type;
+ typedef typename property_traits<map_type>::value_type value_type;
+ typedef typename graph_traits<Graph>::edge_descriptor key_type;
+
+ static const_map_type index_map(const Graph& g)
+ { return get(edge_index, g); }
+
+ static map_type index_map(Graph& g)
+ { return get(edge_index, g); }
+
+ static value_type index(key_type k, const Graph& g)
+ { return get(edge_index, g, k); }
+ };
+
+ template <typename Graph, typename Key>
+ struct choose_indexer
+ {
+ typedef typename mpl::if_<
+ is_same<Key, typename graph_traits<Graph>::vertex_descriptor>,
+ vertex_indexer<Graph>,
+ edge_indexer<Graph>
+ >::type indexer_type;
+ typedef typename indexer_type::index_type index_type;
+ };
+ }
+}
+
+#endif


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk