diff --git a/include/boost/graph/detail/adjacency_list.hpp b/include/boost/graph/detail/adjacency_list.hpp
index 6fb497d7e..a8c92df1d 100644
--- a/include/boost/graph/detail/adjacency_list.hpp
+++ b/include/boost/graph/detail/adjacency_list.hpp
@@ -2058,13 +2058,17 @@ namespace boost {
{
typename EdgeList::iterator ei = el.begin(), e_end = el.end();
while (ei != e_end) {
- typename EdgeList::value_type ce = *ei;
- ++ei;
- if (ce.get_target() > u) {
+ if (ei->get_target() > u) {
+ typename EdgeList::value_type ce = *ei;
+ ++ei;
el.erase(ce);
--ce.get_target();
el.insert(ce);
}
+ else
+ {
+ ++ei;
+ }
}
}
} // namespace detail
diff --git a/test/Jamfile.v2 b/test/Jamfile.v2
index 263365cb5..5677361e5 100644
--- a/test/Jamfile.v2
+++ b/test/Jamfile.v2
@@ -137,6 +137,7 @@ test-suite graph_test :
[ run strong_components_test.cpp ]
[ run find_flow_cost_bundled_properties_and_named_params_test.cpp ../../test/build//boost_unit_test_framework/static ]
[ run max_flow_algorithms_bundled_properties_and_named_params.cpp ../../test/build//boost_unit_test_framework/static ]
+ [ run remove_vertex.cpp ]
;
# Run SDB tests only when -sSDB= is set.
diff --git a/test/remove_vertex.cpp b/test/remove_vertex.cpp
new file mode 100644
index 000000000..342796b6e
--- /dev/null
+++ b/test/remove_vertex.cpp
@@ -0,0 +1,57 @@
+//=======================================================================
+// Copyright 2018
+// Authors: Rasmus Ahlberg
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//=======================================================================
+
+#include
+
+#include
+
+#include
+
+int test_main(int argc, char* argv[])
+{
+ typedef int Vertex;
+ typedef int Edge;
+
+ typedef boost::adjacency_list Graph_t;
+
+ typedef Graph_t::edge_descriptor EdgeDesc;
+
+
+ Graph_t m_graph;
+
+ auto v1 = boost::add_vertex(m_graph);
+ auto v2 = boost::add_vertex(m_graph);
+ auto v3 = boost::add_vertex(m_graph);
+
+ EdgeDesc ed1;
+ bool inserted1;
+
+ boost::tie(ed1, inserted1) = boost::add_edge(v3, v1, m_graph);
+
+ BOOST_REQUIRE(inserted1);
+
+ static const int EDGE_VAL = 1234;
+
+ m_graph[ed1] = EDGE_VAL;
+
+ boost::remove_vertex(v2, m_graph);
+
+ std::cout << "ed1 " << m_graph[ed1] << std::endl;
+
+ BOOST_REQUIRE(m_graph[ed1] == EDGE_VAL);
+
+ return 0;
+}