COIN-OR::LEMON - Graph Library

Changeset 2286:1ef281b2b10e in lemon-0.x


Ignore:
Timestamp:
10/31/06 15:41:12 (13 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3051
Message:

The implementation of the graph copy is changed
Make explicit more constructors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/graph_utils.h

    r2235 r2286  
    8484    typedef Graph:: UEdgeIt UEdgeIt;                    \
    8585    typedef Graph:: IncEdgeIt   IncEdgeIt;                     
    86 //     typedef Graph::template UEdgeMap<bool> BoolUEdgeMap;     
    87 //     typedef Graph::template UEdgeMap<int> IntUEdgeMap;
    88 //     typedef Graph::template UEdgeMap<double> DoubleUEdgeMap;
    8986
    9087  ///\brief Creates convenience typedefs for the bipartite undirected graph
     
    104101#define BPUGRAPH_TYPEDEFS(Graph)            \
    105102  UGRAPH_TYPEDEFS(Graph)                    \
     103    typedef Graph::ANode ANode;             \
     104    typedef Graph::BNode BNode;             \
    106105    typedef Graph::ANodeIt ANodeIt;         \
    107106    typedef Graph::BNodeIt BNodeIt;
     
    380379  ///\sa ConEdgeIt
    381380  template <typename Graph>
    382   inline typename Graph::Edge findEdge(const Graph &g,
    383                                        typename Graph::Node u,
    384                                        typename Graph::Node v,
    385                                        typename Graph::Edge prev = INVALID) {
     381  inline typename Graph::Edge
     382  findEdge(const Graph &g, typename Graph::Node u, typename Graph::Node v,
     383           typename Graph::Edge prev = INVALID) {
    386384    return _graph_utils_bits::FindEdgeSelector<Graph>::find(g, u, v, prev);
    387385  }
     
    507505
    508506  template <typename Graph>
    509   inline typename Graph::UEdge findUEdge(const Graph &g,
    510                                          typename Graph::Node u,
    511                                          typename Graph::Node v,
    512                                          typename Graph::UEdge p = INVALID) {
     507  inline typename Graph::UEdge
     508  findUEdge(const Graph &g, typename Graph::Node u, typename Graph::Node v,
     509            typename Graph::UEdge p = INVALID) {
    513510    return _graph_utils_bits::FindUEdgeSelector<Graph>::find(g, u, v, p);
    514511  }
     
    589586  }
    590587
     588  namespace _graph_utils_bits {
     589
     590    template <typename Graph, typename Item, typename RefMap>
     591    class MapCopyBase {
     592    public:
     593      virtual void copy(const Graph& source, const RefMap& refMap) = 0;
     594     
     595      virtual ~MapCopyBase() {}
     596    };
     597
     598    template <typename Graph, typename Item, typename RefMap,
     599              typename TargetMap, typename SourceMap>
     600    class MapCopy : public MapCopyBase<Graph, Item, RefMap> {
     601    public:
     602
     603      MapCopy(TargetMap& tmap, const SourceMap& map)
     604        : _tmap(tmap), _map(map) {}
     605     
     606      virtual void copy(const Graph& graph, const RefMap& refMap) {
     607        typedef typename ItemSetTraits<Graph, Item>::ItemIt ItemIt;
     608        for (ItemIt it(graph); it != INVALID; ++it) {
     609          _tmap.set(refMap[it], _map[it]);
     610        }
     611      }
     612
     613    private:
     614      TargetMap& _tmap;
     615      const SourceMap& _map;
     616    };
     617
     618    template <typename Graph, typename Item, typename RefMap, typename Ref>
     619    class RefCopy : public MapCopyBase<Graph, Item, RefMap> {
     620    public:
     621
     622      RefCopy(Ref& map) : _map(map) {}
     623     
     624      virtual void copy(const Graph& graph, const RefMap& refMap) {
     625        typedef typename ItemSetTraits<Graph, Item>::ItemIt ItemIt;
     626        for (ItemIt it(graph); it != INVALID; ++it) {
     627          _map.set(it, refMap[it]);
     628        }
     629      }
     630
     631    private:
     632      Ref& _map;
     633    };
     634
     635    template <typename Graph, typename Item, typename RefMap,
     636              typename CrossRef>
     637    class CrossRefCopy : public MapCopyBase<Graph, Item, RefMap> {
     638    public:
     639
     640      CrossRefCopy(CrossRef& cmap) : _cmap(cmap) {}
     641     
     642      virtual void copy(const Graph& graph, const RefMap& refMap) {
     643        typedef typename ItemSetTraits<Graph, Item>::ItemIt ItemIt;
     644        for (ItemIt it(graph); it != INVALID; ++it) {
     645          _cmap.set(refMap[it], it);
     646        }
     647      }
     648
     649    private:
     650      CrossRef& _cmap;
     651    };
     652
     653  }
     654
    591655  /// \brief Class to copy a graph.
    592656  ///
     
    595659  template <typename Target, typename Source>
    596660  class GraphCopy {
    597   public:
     661  private:
     662
    598663    typedef typename Source::Node Node;
    599664    typedef typename Source::NodeIt NodeIt;
     
    601666    typedef typename Source::EdgeIt EdgeIt;
    602667
    603     typedef typename Source::template NodeMap<typename Target::Node>NodeRefMap;
    604     typedef typename Source::template EdgeMap<typename Target::Edge>EdgeRefMap;
     668    typedef typename Target::Node TNode;
     669    typedef typename Target::Edge TEdge;
     670
     671    typedef typename Source::template NodeMap<TNode> NodeRefMap;
     672    typedef typename Source::template EdgeMap<TEdge> EdgeRefMap;
     673   
     674   
     675  public:
     676
    605677
    606678    /// \brief Constructor for the GraphCopy.
    607679    ///
    608680    /// It copies the content of the \c _source graph into the
    609     /// \c _target graph. It creates also two references, one beetween
    610     /// the two nodeset and one beetween the two edgesets.
     681    /// \c _target graph.
    611682    GraphCopy(Target& _target, const Source& _source)
    612       : source(_source), target(_target),
    613         nodeRefMap(_source), edgeRefMap(_source) {
    614       for (NodeIt it(source); it != INVALID; ++it) {
    615         nodeRefMap[it] = target.addNode();
    616       }
    617       for (EdgeIt it(source); it != INVALID; ++it) {
    618         edgeRefMap[it] = target.addEdge(nodeRefMap[source.source(it)],
    619                                         nodeRefMap[source.target(it)]);
    620       }
     683      : source(_source), target(_target) {}
     684
     685    /// \brief Destructor of the GraphCopy
     686    ///
     687    /// Destructor of the GraphCopy
     688    ~GraphCopy() {
     689      for (int i = 0; i < (int)nodeMapCopies.size(); ++i) {
     690        delete nodeMapCopies[i];
     691      }
     692      for (int i = 0; i < (int)edgeMapCopies.size(); ++i) {
     693        delete edgeMapCopies[i];
     694      }
     695
    621696    }
    622697
     
    625700    /// Copies the node references into the given map.
    626701    template <typename NodeRef>
    627     const GraphCopy& nodeRef(NodeRef& map) const {
    628       for (NodeIt it(source); it != INVALID; ++it) {
    629         map.set(it, nodeRefMap[it]);
    630       }
     702    GraphCopy& nodeRef(NodeRef& map) {
     703      nodeMapCopies.push_back(new _graph_utils_bits::RefCopy<Source, Node,
     704                              NodeRefMap, NodeRef>(map));
    631705      return *this;
    632706    }
     
    635709    ///
    636710    /// Reverse and copies the node references into the given map.
    637     template <typename NodeRef>
    638     const GraphCopy& nodeCrossRef(NodeRef& map) const {
    639       for (NodeIt it(source); it != INVALID; ++it) {
    640         map.set(nodeRefMap[it], it);
    641       }
    642       return *this;
    643     }
    644 
    645     /// \brief Copies the edge references into the given map.
    646     ///
    647     /// Copies the edge references into the given map.
    648     template <typename EdgeRef>
    649     const GraphCopy& edgeRef(EdgeRef& map) const {
    650       for (EdgeIt it(source); it != INVALID; ++it) {
    651         map.set(it, edgeRefMap[it]);
    652       }
    653       return *this;
    654     }
    655 
    656     /// \brief Reverse and copies the edge references into the given map.
    657     ///
    658     /// Reverse and copies the edge references into the given map.
    659     template <typename EdgeRef>
    660     const GraphCopy& edgeCrossRef(EdgeRef& map) const {
    661       for (EdgeIt it(source); it != INVALID; ++it) {
    662         map.set(edgeRefMap[it], it);
    663       }
     711    template <typename NodeCrossRef>
     712    GraphCopy& nodeCrossRef(NodeCrossRef& map) {
     713      nodeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<Source, Node,
     714                              NodeRefMap, NodeCrossRef>(map));
    664715      return *this;
    665716    }
     
    672723    /// type. 
    673724    template <typename TargetMap, typename SourceMap>
    674     const GraphCopy& nodeMap(TargetMap& tMap, const SourceMap& sMap) const {
    675       copyMap(tMap, sMap, NodeIt(source), nodeRefMap);
     725    GraphCopy& nodeMap(TargetMap& tmap, const SourceMap& map) {
     726      nodeMapCopies.push_back(new _graph_utils_bits::MapCopy<Source, Node,
     727                              NodeRefMap, TargetMap, SourceMap>(tmap, map));
     728      return *this;
     729    }
     730
     731    /// \brief Copies the edge references into the given map.
     732    ///
     733    /// Copies the edge references into the given map.
     734    template <typename EdgeRef>
     735    GraphCopy& edgeRef(EdgeRef& map) {
     736      edgeMapCopies.push_back(new _graph_utils_bits::RefCopy<Source, Edge,
     737                              EdgeRefMap, EdgeRef>(map));
     738      return *this;
     739    }
     740
     741    /// \brief Reverse and copies the edge references into the given map.
     742    ///
     743    /// Reverse and copies the edge references into the given map.
     744    template <typename EdgeCrossRef>
     745    GraphCopy& edgeCrossRef(EdgeCrossRef& map) {
     746      edgeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<Source, Edge,
     747                              EdgeRefMap, EdgeCrossRef>(map));
    676748      return *this;
    677749    }
     
    684756    /// type. 
    685757    template <typename TargetMap, typename SourceMap>
    686     const GraphCopy& edgeMap(TargetMap& tMap, const SourceMap& sMap) const {
    687       copyMap(tMap, sMap, EdgeIt(source), edgeRefMap);
     758    GraphCopy& edgeMap(TargetMap& tmap, const SourceMap& map) {
     759      edgeMapCopies.push_back(new _graph_utils_bits::MapCopy<Source, Edge,
     760                              EdgeRefMap, TargetMap, SourceMap>(tmap, map));
    688761      return *this;
    689762    }
    690763
    691     /// \brief Gives back the stored node references.
    692     ///
    693     /// Gives back the stored node references.
    694     const NodeRefMap& nodeRef() const {
    695       return nodeRefMap;
    696     }
    697 
    698     /// \brief Gives back the stored edge references.
    699     ///
    700     /// Gives back the stored edge references.
    701     const EdgeRefMap& edgeRef() const {
    702       return edgeRefMap;
    703     }
    704 
    705     void run() const {}
     764    /// \brief Executes the copies.
     765    ///
     766    /// Executes the copies.
     767    void run() {
     768      NodeRefMap nodeRefMap(source);
     769      for (NodeIt it(source); it != INVALID; ++it) {
     770        nodeRefMap[it] = target.addNode();
     771      }
     772      for (int i = 0; i < (int)nodeMapCopies.size(); ++i) {
     773        nodeMapCopies[i]->copy(source, nodeRefMap);
     774      }
     775      EdgeRefMap edgeRefMap(source);
     776      for (EdgeIt it(source); it != INVALID; ++it) {
     777        edgeRefMap[it] = target.addEdge(nodeRefMap[source.source(it)],
     778                                        nodeRefMap[source.target(it)]);
     779      }
     780      for (int i = 0; i < (int)edgeMapCopies.size(); ++i) {
     781        edgeMapCopies[i]->copy(source, edgeRefMap);
     782      }
     783    }
    706784
    707785  private:
     
    710788    Target& target;
    711789
    712     NodeRefMap nodeRefMap;
    713     EdgeRefMap edgeRefMap;
     790    std::vector<_graph_utils_bits::MapCopyBase<Source, Node, NodeRefMap>* >
     791    nodeMapCopies;
     792
     793    std::vector<_graph_utils_bits::MapCopyBase<Source, Edge, EdgeRefMap>* >
     794    edgeMapCopies;
     795
    714796  };
    715797
     
    720802  ///
    721803  ///\code
    722   /// copyGraph(trg, src).nodeRef(nr).edgeCrossRef(ecr);
     804  /// copyGraph(trg, src).nodeRef(nr).edgeCrossRef(ecr).run();
    723805  ///\endcode
    724806  ///
     
    738820  template <typename Target, typename Source>
    739821  class UGraphCopy {
    740   public:
     822  private:
     823
    741824    typedef typename Source::Node Node;
    742825    typedef typename Source::NodeIt NodeIt;
     
    746829    typedef typename Source::UEdgeIt UEdgeIt;
    747830
    748     typedef typename Source::
    749     template NodeMap<typename Target::Node> NodeRefMap;
    750    
    751     typedef typename Source::
    752     template UEdgeMap<typename Target::UEdge> UEdgeRefMap;
    753 
    754   private:
     831    typedef typename Target::Node TNode;
     832    typedef typename Target::Edge TEdge;
     833    typedef typename Target::UEdge TUEdge;
     834
     835    typedef typename Source::template NodeMap<TNode> NodeRefMap;
     836    typedef typename Source::template UEdgeMap<TUEdge> UEdgeRefMap;
    755837
    756838    struct EdgeRefMap {
    757       EdgeRefMap(UGraphCopy& _gc) : gc(_gc) {}
     839      EdgeRefMap(const Target& _target, const Source& _source,
     840                 const UEdgeRefMap& _uedge_ref, const NodeRefMap& _node_ref)
     841        : target(_target), source(_source),
     842          uedge_ref(_uedge_ref), node_ref(_node_ref) {}
     843
    758844      typedef typename Source::Edge Key;
    759845      typedef typename Target::Edge Value;
    760846
    761       Value operator[](const Key& key) {
    762         return gc.target.direct(gc.uEdgeRef[key],
    763                                 gc.target.direction(key));
     847      Value operator[](const Key& key) const {
     848        bool forward = (source.direction(key) ==
     849                        (node_ref[source.source((UEdge)key)] ==
     850                         target.source(uedge_ref[(UEdge)key])));
     851        return target.direct(uedge_ref[key], forward);
    764852      }
    765853     
    766       UGraphCopy& gc;
     854      const Target& target;
     855      const Source& source;
     856      const UEdgeRefMap& uedge_ref;
     857      const NodeRefMap& node_ref;
    767858    };
    768    
    769   public:
    770 
    771     /// \brief Constructor for the UGraphCopy.
     859
     860   
     861  public:
     862
     863
     864    /// \brief Constructor for the GraphCopy.
    772865    ///
    773866    /// It copies the content of the \c _source graph into the
    774     /// \c _target graph. It creates also two references, one beetween
    775     /// the two nodeset and one beetween the two edgesets.
     867    /// \c _target graph.
    776868    UGraphCopy(Target& _target, const Source& _source)
    777       : source(_source), target(_target),
    778         nodeRefMap(_source), edgeRefMap(*this), uEdgeRefMap(_source) {
    779       for (NodeIt it(source); it != INVALID; ++it) {
    780         nodeRefMap[it] = target.addNode();
    781       }
    782       for (UEdgeIt it(source); it != INVALID; ++it) {
    783         uEdgeRefMap[it] = target.addEdge(nodeRefMap[source.source(it)],
    784                                         nodeRefMap[source.target(it)]);
    785       }
     869      : source(_source), target(_target) {}
     870
     871    /// \brief Destructor of the GraphCopy
     872    ///
     873    /// Destructor of the GraphCopy
     874    ~UGraphCopy() {
     875      for (int i = 0; i < (int)nodeMapCopies.size(); ++i) {
     876        delete nodeMapCopies[i];
     877      }
     878      for (int i = 0; i < (int)edgeMapCopies.size(); ++i) {
     879        delete edgeMapCopies[i];
     880      }
     881      for (int i = 0; i < (int)uEdgeMapCopies.size(); ++i) {
     882        delete uEdgeMapCopies[i];
     883      }
     884
    786885    }
    787886
     
    790889    /// Copies the node references into the given map.
    791890    template <typename NodeRef>
    792     const UGraphCopy& nodeRef(NodeRef& map) const {
    793       for (NodeIt it(source); it != INVALID; ++it) {
    794         map.set(it, nodeRefMap[it]);
    795       }
     891    UGraphCopy& nodeRef(NodeRef& map) {
     892      nodeMapCopies.push_back(new _graph_utils_bits::RefCopy<Source, Node,
     893                              NodeRefMap, NodeRef>(map));
    796894      return *this;
    797895    }
     
    800898    ///
    801899    /// Reverse and copies the node references into the given map.
    802     template <typename NodeRef>
    803     const UGraphCopy& nodeCrossRef(NodeRef& map) const {
    804       for (NodeIt it(source); it != INVALID; ++it) {
    805         map.set(nodeRefMap[it], it);
    806       }
    807       return *this;
    808     }
    809 
    810     /// \brief Copies the edge references into the given map.
    811     ///
    812     /// Copies the edge references into the given map.
    813     template <typename EdgeRef>
    814     const UGraphCopy& edgeRef(EdgeRef& map) const {
    815       for (EdgeIt it(source); it != INVALID; ++it) {
    816         map.set(edgeRefMap[it], it);
    817       }
    818       return *this;
    819     }
    820 
    821     /// \brief Reverse and copies the undirected edge references into the
    822     /// given map.
    823     ///
    824     /// Reverse and copies the undirected edge references into the given map.
    825     template <typename EdgeRef>
    826     const UGraphCopy& edgeCrossRef(EdgeRef& map) const {
    827       for (EdgeIt it(source); it != INVALID; ++it) {
    828         map.set(it, edgeRefMap[it]);
    829       }
    830       return *this;
    831     }
    832 
    833     /// \brief Copies the undirected edge references into the given map.
    834     ///
    835     /// Copies the undirected edge references into the given map.
    836     template <typename EdgeRef>
    837     const UGraphCopy& uEdgeRef(EdgeRef& map) const {
    838       for (UEdgeIt it(source); it != INVALID; ++it) {
    839         map.set(it, uEdgeRefMap[it]);
    840       }
    841       return *this;
    842     }
    843 
    844     /// \brief Reverse and copies the undirected edge references into the
    845     /// given map.
    846     ///
    847     /// Reverse and copies the undirected edge references into the given map.
    848     template <typename EdgeRef>
    849     const UGraphCopy& uEdgeCrossRef(EdgeRef& map) const {
    850       for (UEdgeIt it(source); it != INVALID; ++it) {
    851         map.set(uEdgeRefMap[it], it);
    852       }
     900    template <typename NodeCrossRef>
     901    UGraphCopy& nodeCrossRef(NodeCrossRef& map) {
     902      nodeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<Source, Node,
     903                              NodeRefMap, NodeCrossRef>(map));
    853904      return *this;
    854905    }
     
    861912    /// type. 
    862913    template <typename TargetMap, typename SourceMap>
    863     const UGraphCopy& nodeMap(TargetMap& tMap,
    864                                   const SourceMap& sMap) const {
    865       copyMap(tMap, sMap, NodeIt(source), nodeRefMap);
     914    UGraphCopy& nodeMap(TargetMap& tmap, const SourceMap& map) {
     915      nodeMapCopies.push_back(new _graph_utils_bits::MapCopy<Source, Node,
     916                              NodeRefMap, TargetMap, SourceMap>(tmap, map));
     917      return *this;
     918    }
     919
     920    /// \brief Copies the edge references into the given map.
     921    ///
     922    /// Copies the edge references into the given map.
     923    template <typename EdgeRef>
     924    UGraphCopy& edgeRef(EdgeRef& map) {
     925      edgeMapCopies.push_back(new _graph_utils_bits::RefCopy<Source, Edge,
     926                              EdgeRefMap, EdgeRef>(map));
     927      return *this;
     928    }
     929
     930    /// \brief Reverse and copies the edge references into the given map.
     931    ///
     932    /// Reverse and copies the edge references into the given map.
     933    template <typename EdgeCrossRef>
     934    UGraphCopy& edgeCrossRef(EdgeCrossRef& map) {
     935      edgeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<Source, Edge,
     936                              EdgeRefMap, EdgeCrossRef>(map));
    866937      return *this;
    867938    }
     
    874945    /// type. 
    875946    template <typename TargetMap, typename SourceMap>
    876     const UGraphCopy& edgeMap(TargetMap& tMap,
    877                                   const SourceMap& sMap) const {
    878       copyMap(tMap, sMap, EdgeIt(source), edgeRefMap);
     947    UGraphCopy& edgeMap(TargetMap& tmap, const SourceMap& map) {
     948      edgeMapCopies.push_back(new _graph_utils_bits::MapCopy<Source, Edge,
     949                              EdgeRefMap, TargetMap, SourceMap>(tmap, map));
    879950      return *this;
    880951    }
    881952
     953    /// \brief Copies the uEdge references into the given map.
     954    ///
     955    /// Copies the uEdge references into the given map.
     956    template <typename UEdgeRef>
     957    UGraphCopy& uEdgeRef(UEdgeRef& map) {
     958      uEdgeMapCopies.push_back(new _graph_utils_bits::RefCopy<Source, UEdge,
     959                               UEdgeRefMap, UEdgeRef>(map));
     960      return *this;
     961    }
     962
     963    /// \brief Reverse and copies the uEdge references into the given map.
     964    ///
     965    /// Reverse and copies the uEdge references into the given map.
     966    template <typename UEdgeCrossRef>
     967    UGraphCopy& uEdgeCrossRef(UEdgeCrossRef& map) {
     968      uEdgeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<Source,
     969                               UEdge, UEdgeRefMap, UEdgeCrossRef>(map));
     970      return *this;
     971    }
     972
    882973    /// \brief Make copy of the given map.
    883974    ///
    884975    /// Makes copy of the given map for the newly created graph.
    885     /// The new map's key type is the target graph's edge type,
    886     /// and the copied map's key type is the source graph's edge
     976    /// The new map's key type is the target graph's uEdge type,
     977    /// and the copied map's key type is the source graph's uEdge
    887978    /// type. 
    888979    template <typename TargetMap, typename SourceMap>
    889     const UGraphCopy& uEdgeMap(TargetMap& tMap,
    890                                   const SourceMap& sMap) const {
    891       copyMap(tMap, sMap, UEdgeIt(source), uEdgeRefMap);
     980    UGraphCopy& uEdgeMap(TargetMap& tmap, const SourceMap& map) {
     981      uEdgeMapCopies.push_back(new _graph_utils_bits::MapCopy<Source, UEdge,
     982                               UEdgeRefMap, TargetMap, SourceMap>(tmap, map));
    892983      return *this;
    893984    }
    894985
    895     /// \brief Gives back the stored node references.
    896     ///
    897     /// Gives back the stored node references.
    898     const NodeRefMap& nodeRef() const {
    899       return nodeRefMap;
    900     }
    901 
    902     /// \brief Gives back the stored edge references.
    903     ///
    904     /// Gives back the stored edge references.
    905     const EdgeRefMap& edgeRef() const {
    906       return edgeRefMap;
    907     }
    908 
    909     /// \brief Gives back the stored uedge references.
    910     ///
    911     /// Gives back the stored uedge references.
    912     const UEdgeRefMap& uEdgeRef() const {
    913       return uEdgeRefMap;
    914     }
    915 
    916     void run() const {}
     986    /// \brief Executes the copies.
     987    ///
     988    /// Executes the copies.
     989    void run() {
     990      NodeRefMap nodeRefMap(source);
     991      for (NodeIt it(source); it != INVALID; ++it) {
     992        nodeRefMap[it] = target.addNode();
     993      }
     994      for (int i = 0; i < (int)nodeMapCopies.size(); ++i) {
     995        nodeMapCopies[i]->copy(source, nodeRefMap);
     996      }
     997      UEdgeRefMap uEdgeRefMap(source);
     998      EdgeRefMap edgeRefMap(target, source, uEdgeRefMap, nodeRefMap);
     999      for (UEdgeIt it(source); it != INVALID; ++it) {
     1000        uEdgeRefMap[it] = target.addEdge(nodeRefMap[source.source(it)],
     1001                                         nodeRefMap[source.target(it)]);
     1002      }
     1003      for (int i = 0; i < (int)uEdgeMapCopies.size(); ++i) {
     1004        uEdgeMapCopies[i]->copy(source, uEdgeRefMap);
     1005      }
     1006      for (int i = 0; i < (int)edgeMapCopies.size(); ++i) {
     1007        edgeMapCopies[i]->copy(source, edgeRefMap);
     1008      }
     1009    }
    9171010
    9181011  private:
     
    9211014    Target& target;
    9221015
    923     NodeRefMap nodeRefMap;
    924     EdgeRefMap edgeRefMap;
    925     UEdgeRefMap uEdgeRefMap;
     1016    std::vector<_graph_utils_bits::MapCopyBase<Source, Node, NodeRefMap>* >
     1017    nodeMapCopies;
     1018
     1019    std::vector<_graph_utils_bits::MapCopyBase<Source, Edge, EdgeRefMap>* >
     1020    edgeMapCopies;
     1021
     1022    std::vector<_graph_utils_bits::MapCopyBase<Source, UEdge, UEdgeRefMap>* >
     1023    uEdgeMapCopies;
     1024
    9261025  };
    9271026
     
    9321031  ///
    9331032  ///\code
    934   /// copyUGraph(trg, src).nodeRef(nr).edgeCrossRef(ecr);
     1033  /// copyUGraph(trg, src).nodeRef(nr).edgeCrossRef(ecr).run();
    9351034  ///\endcode
    9361035  ///
     
    9721071    ///
    9731072    /// Constructor for creating id map.
    974     IdMap(const Graph& _graph) : graph(&_graph) {}
     1073    explicit IdMap(const Graph& _graph) : graph(&_graph) {}
    9751074
    9761075    /// \brief Gives back the \e id of the item.
     
    9951094      ///
    9961095      /// Constructor for creating an id-to-item map.
    997       InverseMap(const Graph& _graph) : graph(&_graph) {}
     1096      explicit InverseMap(const Graph& _graph) : graph(&_graph) {}
    9981097
    9991098      /// \brief Constructor.
    10001099      ///
    10011100      /// Constructor for creating an id-to-item map.
    1002       InverseMap(const IdMap& idMap) : graph(idMap.graph) {}
     1101      explicit InverseMap(const IdMap& idMap) : graph(idMap.graph) {}
    10031102
    10041103      /// \brief Gives back the given item from its id.
     
    10671166    /// Construct a new InvertableMap for the graph.
    10681167    ///
    1069     InvertableMap(const Graph& graph) : Map(graph) {}
     1168    explicit InvertableMap(const Graph& graph) : Map(graph) {}
    10701169
    10711170    /// \brief Forward iterator for values.
     
    11931292      ///
    11941293      /// Constructor of the InverseMap.
    1195       InverseMap(const InvertableMap& _inverted) : inverted(_inverted) {}
     1294      explicit InverseMap(const InvertableMap& _inverted)
     1295        : inverted(_inverted) {}
    11961296
    11971297      /// The value type of the InverseMap.
     
    12651365    ///
    12661366    /// Constructor for descriptor map.
    1267     DescriptorMap(const Graph& _graph) : Map(_graph) {
     1367    explicit DescriptorMap(const Graph& _graph) : Map(_graph) {
    12681368      Item it;
    12691369      const typename Map::Notifier* notifier = Map::getNotifier();
     
    12731373      }     
    12741374    }
     1375
    12751376
    12761377  protected:
     
    13871488      ///
    13881489      /// Constructor of the InverseMap.
    1389       InverseMap(const DescriptorMap& _inverted)
     1490      explicit InverseMap(const DescriptorMap& _inverted)
    13901491        : inverted(_inverted) {}
    13911492
     
    14381539    /// Constructor
    14391540    /// \param _graph The graph that the map belongs to.
    1440     SourceMap(const Graph& _graph) : graph(_graph) {}
     1541    explicit SourceMap(const Graph& _graph) : graph(_graph) {}
    14411542
    14421543    /// \brief The subscript operator.
     
    14771578    /// Constructor
    14781579    /// \param _graph The graph that the map belongs to.
    1479     TargetMap(const Graph& _graph) : graph(_graph) {}
     1580    explicit TargetMap(const Graph& _graph) : graph(_graph) {}
    14801581
    14811582    /// \brief The subscript operator.
     
    15161617    /// Constructor
    15171618    /// \param _graph The graph that the map belongs to.
    1518     ForwardMap(const Graph& _graph) : graph(_graph) {}
     1619    explicit ForwardMap(const Graph& _graph) : graph(_graph) {}
    15191620
    15201621    /// \brief The subscript operator.
     
    15551656    /// Constructor
    15561657    /// \param _graph The graph that the map belongs to.
    1557     BackwardMap(const Graph& _graph) : graph(_graph) {}
     1658    explicit BackwardMap(const Graph& _graph) : graph(_graph) {}
    15581659
    15591660    /// \brief The subscript operator.
     
    15931694    ///
    15941695    /// Contructor of the map
    1595     PotentialDifferenceMap(const Graph& _graph, const NodeMap& _potential)
     1696    explicit PotentialDifferenceMap(const Graph& _graph,
     1697                                    const NodeMap& _potential)
    15961698      : graph(_graph), potential(_potential) {}
    15971699
     
    16771779    ///
    16781780    /// Constructor for creating in-degree map.
    1679     InDegMap(const Graph& _graph) : graph(_graph), deg(_graph) {
     1781    explicit InDegMap(const Graph& _graph) : graph(_graph), deg(_graph) {
    16801782      Parent::attach(graph.getNotifier(typename _Graph::Edge()));
    16811783     
     
    17891891    ///
    17901892    /// Constructor for creating out-degree map.
    1791     OutDegMap(const Graph& _graph) : graph(_graph), deg(_graph) {
     1893    explicit OutDegMap(const Graph& _graph) : graph(_graph), deg(_graph) {
    17921894      Parent::attach(graph.getNotifier(typename _Graph::Edge()));
    17931895     
Note: See TracChangeset for help on using the changeset viewer.