Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67110 - trunk/boost/graph
From: jewillco_at_[hidden]
Date: 2010-12-08 13:11:54


Author: jewillco
Date: 2010-12-08 13:11:52 EST (Wed, 08 Dec 2010)
New Revision: 67110
URL: http://svn.boost.org/trac/boost/changeset/67110

Log:
Applied patch from #4966 to fix self-loop insertion; fixes #4966
Text files modified:
   trunk/boost/graph/subgraph.hpp | 10 ++++++----
   1 files changed, 6 insertions(+), 4 deletions(-)

Modified: trunk/boost/graph/subgraph.hpp
==============================================================================
--- trunk/boost/graph/subgraph.hpp (original)
+++ trunk/boost/graph/subgraph.hpp 2010-12-08 13:11:52 EST (Wed, 08 Dec 2010)
@@ -346,7 +346,7 @@
            subgraph<G>& g)
 {
     assert(!g.is_root());
- typename subgraph<G>::vertex_descriptor u_local, v_global, uu_global;
+ typename subgraph<G>::vertex_descriptor u_local, v_global;
     typename subgraph<G>::edge_descriptor e_global;
 
     u_local = add_vertex(g.m_graph);
@@ -371,11 +371,13 @@
         typename subgraph<G>::out_edge_iterator ei, ei_end;
         for(boost::tie(vi, vi_end) = vertices(r); vi != vi_end; ++vi) {
             v_global = *vi;
- if(g.find_vertex(v_global).second)
+ if (v_global == u_global)
+ continue; // don't insert self loops twice!
+ if (!g.find_vertex(v_global).second)
+ continue; // not a subgraph vertex => try next one
             for(boost::tie(ei, ei_end) = out_edges(*vi, r); ei != ei_end; ++ei) {
                 e_global = *ei;
- uu_global = target(e_global, r);
- if(uu_global == u_global && g.find_vertex(v_global).second) {
+ if(target(e_global, r) == u_global) {
                     g.local_add_edge(g.global_to_local(v_global), u_local, e_global);
                 }
             }


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