Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65198 - trunk/boost/graph/detail
From: jewillco_at_[hidden]
Date: 2010-09-02 14:24:19


Author: jewillco
Date: 2010-09-02 14:24:17 EDT (Thu, 02 Sep 2010)
New Revision: 65198
URL: http://svn.boost.org/trac/boost/changeset/65198

Log:
Fixed clearing of vertices with self-loop edges; fixes #4622
Text files modified:
   trunk/boost/graph/detail/adjacency_list.hpp | 17 +++++++++++++----
   1 files changed, 13 insertions(+), 4 deletions(-)

Modified: trunk/boost/graph/detail/adjacency_list.hpp
==============================================================================
--- trunk/boost/graph/detail/adjacency_list.hpp (original)
+++ trunk/boost/graph/detail/adjacency_list.hpp 2010-09-02 14:24:17 EDT (Thu, 02 Sep 2010)
@@ -993,10 +993,19 @@
       typename Config::OutEdgeList& el = g.out_edge_list(u);
       typename Config::OutEdgeList::iterator
         ei = el.begin(), ei_end = el.end();
- for (; ei != ei_end; ++ei) {
- detail::erase_from_incidence_list
- (g.out_edge_list((*ei).get_target()), u, Cat());
- g.m_edges.erase((*ei).get_iter());
+ for (; ei != ei_end; /* Increment below */ ) {
+ bool is_self_loop = (*ei).get_target() == u;
+ // Don't erase from our own incidence list in the case of a self-loop
+ // since we're clearing it anyway.
+ if (!is_self_loop) {
+ detail::erase_from_incidence_list
+ (g.out_edge_list((*ei).get_target()), u, Cat());
+ typename Config::OutEdgeList::iterator ei_copy = ei;
+ ++ei;
+ if (!is_self_loop) g.m_edges.erase((*ei_copy).get_iter());
+ } else {
+ ++ei;
+ }
       }
       g.out_edge_list(u).clear();
     }


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