Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82498 - in trunk/boost/graph: . detail distributed
From: jewillco_at_[hidden]
Date: 2013-01-14 16:03:50


Author: jewillco
Date: 2013-01-14 16:03:48 EST (Mon, 14 Jan 2013)
New Revision: 82498
URL: http://svn.boost.org/trac/boost/changeset/82498

Log:
Added check to prevent use of remove_vertex on named adjacency list graphs with vecS vertex container (since it does not work and could not be made to work efficiently); refs #7863
Text files modified:
   trunk/boost/graph/detail/adjacency_list.hpp | 5 +++--
   trunk/boost/graph/distributed/adjacency_list.hpp | 3 ++-
   trunk/boost/graph/distributed/named_graph.hpp | 6 ++++--
   trunk/boost/graph/named_graph.hpp | 16 ++++++++++++----
   4 files changed, 21 insertions(+), 9 deletions(-)

Modified: trunk/boost/graph/detail/adjacency_list.hpp
==============================================================================
--- trunk/boost/graph/detail/adjacency_list.hpp (original)
+++ trunk/boost/graph/detail/adjacency_list.hpp 2013-01-14 16:03:48 EST (Mon, 14 Jan 2013)
@@ -17,6 +17,7 @@
 #include <boost/detail/workaround.hpp>
 #include <boost/operators.hpp>
 #include <boost/property_map/property_map.hpp>
+#include <boost/pending/container_traits.hpp>
 #include <boost/range/irange.hpp>
 #include <boost/graph/graph_traits.hpp>
 #include <memory>
@@ -1903,7 +1904,7 @@
     {
       typedef typename Config::stored_vertex stored_vertex;
       Derived& g = static_cast<Derived&>(g_);
- g.removing_vertex(u);
+ g.removing_vertex(u, boost::graph_detail::iterator_stability(g_.m_vertices));
       stored_vertex* su = (stored_vertex*)u;
       g.m_vertices.erase(su->m_position);
       delete su;
@@ -2203,7 +2204,7 @@
     {
       typedef typename Config::directed_category Cat;
       Graph& g = static_cast<Graph&>(g_);
- g.removing_vertex(v);
+ g.removing_vertex(v, boost::graph_detail::iterator_stability(g_.m_vertices));
       detail::remove_vertex_dispatch(g, v, Cat());
     }
     // O(1)

Modified: trunk/boost/graph/distributed/adjacency_list.hpp
==============================================================================
--- trunk/boost/graph/distributed/adjacency_list.hpp (original)
+++ trunk/boost/graph/distributed/adjacency_list.hpp 2013-01-14 16:03:48 EST (Mon, 14 Jan 2013)
@@ -37,6 +37,7 @@
 #include <boost/graph/parallel/algorithm.hpp>
 #include <boost/graph/distributed/selector.hpp>
 #include <boost/graph/parallel/process_group.hpp>
+#include <boost/pending/container_traits.hpp>
 
 // Callbacks
 #include <boost/function/function2.hpp>
@@ -3427,7 +3428,7 @@
     typedef typename graph_type::named_graph_mixin named_graph_mixin;
     BOOST_ASSERT(u.owner == g.processor());
     static_cast<named_graph_mixin&>(static_cast<graph_type&>(g))
- .removing_vertex(u);
+ .removing_vertex(u, boost::graph_detail::iterator_stability(g.base().m_vertices));
     g.distribution().clear();
     remove_vertex(u.local, g.base());
   }

Modified: trunk/boost/graph/distributed/named_graph.hpp
==============================================================================
--- trunk/boost/graph/distributed/named_graph.hpp (original)
+++ trunk/boost/graph/distributed/named_graph.hpp 2013-01-14 16:03:48 EST (Mon, 14 Jan 2013)
@@ -267,7 +267,8 @@
 
   /// Notify the named_graph that we are removing the given
   /// vertex. This is a no-op.
- void removing_vertex(Vertex) { }
+ template <typename VertexIterStability>
+ void removing_vertex(Vertex, VertexIterStability) { }
 
   /// Notify the named_graph that we are clearing the graph
   void clearing_graph() { }
@@ -1211,7 +1212,8 @@
 
   /// Notify the named_graph that we are removing the given
   /// vertex. This is a no-op.
- void removing_vertex(Vertex) { }
+ template <typename VertexIterStability>
+ void removing_vertex(Vertex, VertexIterStability) { }
 
   /// Notify the named_graph that we are clearing the graph
   void clearing_graph() { }

Modified: trunk/boost/graph/named_graph.hpp
==============================================================================
--- trunk/boost/graph/named_graph.hpp (original)
+++ trunk/boost/graph/named_graph.hpp 2013-01-14 16:03:48 EST (Mon, 14 Jan 2013)
@@ -11,6 +11,7 @@
 #define BOOST_GRAPH_NAMED_GRAPH_HPP
 
 #include <boost/config.hpp>
+#include <boost/static_assert.hpp>
 #include <boost/functional/hash.hpp>
 #include <boost/graph/graph_traits.hpp>
 #include <boost/graph/properties.hpp>
@@ -19,9 +20,11 @@
 #include <boost/multi_index_container.hpp>
 #include <boost/optional.hpp>
 #include <boost/pending/property.hpp> // for boost::lookup_one_property
+#include <boost/pending/container_traits.hpp>
 #include <boost/throw_exception.hpp>
 #include <boost/tuple/tuple.hpp> // for boost::make_tuple
 #include <boost/type_traits/is_same.hpp>
+#include <boost/type_traits/is_base_of.hpp>
 #include <boost/type_traits/remove_cv.hpp>
 #include <boost/type_traits/remove_reference.hpp>
 #include <boost/utility/enable_if.hpp>
@@ -253,7 +256,8 @@
 
   /// Notify the named_graph that we are removing the given
   /// vertex. The name of the vertex will be removed from the mapping.
- void removing_vertex(Vertex vertex);
+ template <typename VertexIterStability>
+ void removing_vertex(Vertex vertex, VertexIterStability);
 
   /// Notify the named_graph that we are clearing the graph.
   /// This will clear out all of the name->vertex mappings
@@ -308,8 +312,10 @@
 }
 
 template<BGL_NAMED_GRAPH_PARAMS>
-inline void BGL_NAMED_GRAPH::removing_vertex(Vertex vertex)
+template<typename VertexIterStability>
+inline void BGL_NAMED_GRAPH::removing_vertex(Vertex vertex, VertexIterStability)
 {
+ BOOST_STATIC_ASSERT_MSG ((boost::is_base_of<boost::graph_detail::stable_tag, VertexIterStability>::value), "Named graphs cannot use vecS as vertex container and remove vertices; the lack of vertex descriptor stability (which iterator stability is a proxy for) means that the name -> vertex mapping would need to be completely rebuilt after each deletion. See https://svn.boost.org/trac/boost/ticket/7863 for more information and a test case.");
   typedef typename BGL_NAMED_GRAPH::vertex_name_type vertex_name_type;
   const vertex_name_type& vertex_name = extract_name(derived()[vertex]);
   named_vertices.erase(vertex_name);
@@ -486,7 +492,8 @@
 
   /// Notify the named_graph that we are removing the given
   /// vertex. This is a no-op.
- void removing_vertex(Vertex) { }
+ template <typename VertexIterStability>
+ void removing_vertex(Vertex, VertexIterStability) { }
 
   /// Notify the named_graph that we are clearing the graph. This is a
   /// no-op.
@@ -517,7 +524,8 @@
 
   /// Notify the named_graph that we are removing the given
   /// vertex. This is a no-op.
- void removing_vertex(Vertex) { }
+ template <typename VertexIterStability>
+ void removing_vertex(Vertex, VertexIterStability) { }
 
   /// Notify the named_graph that we are clearing the graph. This is a
   /// no-op.


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