Ticket #4966: subgraph.hpp.patch

File subgraph.hpp.patch, 1.3 KB (added by joachim.falk@…, 12 years ago)

Patch file fixing the duplicate vertex loop problem on subgraph vertex add

  • boost/graph/subgraph.hpp

    old new  
    346346           subgraph<G>& g)
    347347{
    348348    assert(!g.is_root());
    349     typename subgraph<G>::vertex_descriptor u_local, v_global, uu_global;
     349    typename subgraph<G>::vertex_descriptor u_local, v_global;
    350350    typename subgraph<G>::edge_descriptor e_global;
    351351
    352352    u_local = add_vertex(g.m_graph);
     
    371371        typename subgraph<G>::out_edge_iterator ei, ei_end;
    372372        for(boost::tie(vi, vi_end) = vertices(r); vi != vi_end; ++vi) {
    373373            v_global = *vi;
    374             if(g.find_vertex(v_global).second)
     374            if (v_global == u_global)
     375                continue; // don't insert self loops twice!
     376            if (!g.find_vertex(v_global).second)
     377                continue; // not a subgraph vertex => try next one
    375378            for(boost::tie(ei, ei_end) = out_edges(*vi, r); ei != ei_end; ++ei) {
    376379                e_global = *ei;
    377                 uu_global = target(e_global, r);
    378                 if(uu_global == u_global && g.find_vertex(v_global).second) {
     380                if(target(e_global, r) == u_global) {
    379381                    g.local_add_edge(g.global_to_local(v_global), u_local, e_global);
    380382                }
    381383            }