Ticket #6564: subgraph.hpp.2.patch

File subgraph.hpp.2.patch, 1.3 KB (added by ernest.galbrun@…, 11 years ago)

patch

  • subgraph.hpp

     
    131131
    132132    // copy constructor
    133133    subgraph(const subgraph& x)
    134         : m_graph(x.m_graph), m_parent(x.m_parent), m_edge_counter(x.m_edge_counter)
     134        : m_parent(x.m_parent), m_edge_counter(x.m_edge_counter)
    135135        , m_global_vertex(x.m_global_vertex), m_global_edge(x.m_global_edge)
    136136    {
    137         // Do a deep copy (recursive).
    138         for(typename ChildrenList::const_iterator i = x.m_children.begin();
    139             i != x.m_children.end(); ++i)
     137        if(x.is_root())
    140138        {
    141             m_children.push_back(new subgraph<Graph>( **i ));
     139         m_graph = x.m_graph;
    142140        }
     141        // Do a deep copy (recursive).
     142        // Only the root graph is copied, the subgraphes contain
     143        // only references to the global vertices they own.
     144        subgraph<Graph>::children_iterator i,i_end;
     145        boost::tie(i,i_end) = x.children();
     146        for(; i != i_end; ++i)
     147        {         
     148         subgraph<Graph> child = this->create_subgraph();
     149         child = *i;
     150         vertex_iterator vi,vi_end;   
     151         boost::tie(vi,vi_end) = vertices(*i);
     152         for (;vi!=vi_end;++vi) 
     153         {
     154          add_vertex(*vi,child);
     155         }
     156       }
    143157    }
    144158
    145159