From e2db737d1b01327bdb9d3154ce7bfa3331dada34 Mon Sep 17 00:00:00 2001 From: Rasmus Ahlberg Date: Mon, 30 Jul 2018 12:15:25 +0200 Subject: [PATCH 1/4] Don't copy value if not needed, as source's m_property will be set to null when copied. See https://svn.boost.org/trac10/ticket/13544. --- include/boost/graph/detail/adjacency_list.hpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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 From e8d7c9fe9bc548ebcd59a5fcc659e216c8c23cd8 Mon Sep 17 00:00:00 2001 From: Rasmus Ahlberg Date: Thu, 23 Aug 2018 16:22:06 +0200 Subject: [PATCH 2/4] Added test case for removing edges bug from previous commit. --- test/Jamfile.v2 | 1 + test/delete_edge.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 test/delete_edge.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 263365cb5..f0c54d146 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_edge.cpp ] ; # Run SDB tests only when -sSDB= is set. diff --git a/test/delete_edge.cpp b/test/delete_edge.cpp new file mode 100644 index 000000000..342796b6e --- /dev/null +++ b/test/delete_edge.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; +} From 228a464118503678b574ff8c0c83daf7c9df0cbe Mon Sep 17 00:00:00 2001 From: Rasmus Ahlberg <1029168+raahlb@users.noreply.github.com> Date: Sun, 2 Sep 2018 12:26:04 +0200 Subject: [PATCH 3/4] Rename delete_edge.cpp to remove_vertex.cpp --- test/{delete_edge.cpp => remove_vertex.cpp} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{delete_edge.cpp => remove_vertex.cpp} (100%) diff --git a/test/delete_edge.cpp b/test/remove_vertex.cpp similarity index 100% rename from test/delete_edge.cpp rename to test/remove_vertex.cpp From 88fc735807ddf1a3da9b544232d70649811fa9b2 Mon Sep 17 00:00:00 2001 From: Rasmus Ahlberg <1029168+raahlb@users.noreply.github.com> Date: Sun, 2 Sep 2018 12:27:34 +0200 Subject: [PATCH 4/4] Fixed erroneous test filename --- test/Jamfile.v2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index f0c54d146..5677361e5 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -137,7 +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_edge.cpp ] + [ run remove_vertex.cpp ] ; # Run SDB tests only when -sSDB= is set.