COIN-OR::LEMON - Graph Library

Ticket #371: 371-bugfix-50446fbc0602.patch

File 371-bugfix-50446fbc0602.patch, 1.1 KB (added by Peter Kovacs, 14 years ago)
  • lemon/core.h

    # HG changeset patch
    # User Peter Kovacs <kpeter@inf.elte.hu>
    # Date 1277213966 -7200
    # Node ID 50446fbc0602435ce6d92911272a07c3b61286cf
    # Parent  1aa7eba26af5b7d5d7962840670e1d73299ce7ee
    Bug fix in (di)graphCopy() (#371)
    
    The target graph is cleared before adding nodes and arcs/edges.
    
    diff --git a/lemon/core.h b/lemon/core.h
    a b  
    384384      template <typename From, typename NodeRefMap, typename ArcRefMap>
    385385      static void copy(const From& from, Digraph &to,
    386386                       NodeRefMap& nodeRefMap, ArcRefMap& arcRefMap) {
     387        to.clear();
    387388        for (typename From::NodeIt it(from); it != INVALID; ++it) {
    388389          nodeRefMap[it] = to.addNode();
    389390        }
     
    411412      template <typename From, typename NodeRefMap, typename EdgeRefMap>
    412413      static void copy(const From& from, Graph &to,
    413414                       NodeRefMap& nodeRefMap, EdgeRefMap& edgeRefMap) {
     415        to.clear();
    414416        for (typename From::NodeIt it(from); it != INVALID; ++it) {
    415417          nodeRefMap[it] = to.addNode();
    416418        }