lemon/graph_utils.h
changeset 2485 88aa7870756a
parent 2476 059dcdda37c5
child 2510 bb523a4758f7
     1.1 --- a/lemon/graph_utils.h	Mon Oct 01 19:23:16 2007 +0000
     1.2 +++ b/lemon/graph_utils.h	Tue Oct 02 12:34:43 2007 +0000
     1.3 @@ -146,8 +146,9 @@
     1.4    /// The complexity of the function is O(n) but for some
     1.5    /// graph structures it is specialized to run in O(1).
     1.6    ///
     1.7 -  /// \todo Refer how to specialize it.
     1.8 -
     1.9 +  /// If the graph contains a \e nodeNum() member function and a 
    1.10 +  /// \e NodeNumTag tag then this function calls directly the member
    1.11 +  /// function to query the cardinality of the node set.
    1.12    template <typename Graph>
    1.13    inline int countNodes(const Graph& g) {
    1.14      return _graph_utils_bits::CountNodesSelector<Graph>::count(g);
    1.15 @@ -179,8 +180,9 @@
    1.16    /// The complexity of the function is O(an) but for some
    1.17    /// graph structures it is specialized to run in O(1).
    1.18    ///
    1.19 -  /// \todo Refer how to specialize it.
    1.20 -
    1.21 +  /// If the graph contains an \e aNodeNum() member function and a 
    1.22 +  /// \e NodeNumTag tag then this function calls directly the member
    1.23 +  /// function to query the cardinality of the A-node set.
    1.24    template <typename Graph>
    1.25    inline int countANodes(const Graph& g) {
    1.26      return _graph_utils_bits::CountANodesSelector<Graph>::count(g);
    1.27 @@ -212,8 +214,9 @@
    1.28    /// The complexity of the function is O(bn) but for some
    1.29    /// graph structures it is specialized to run in O(1).
    1.30    ///
    1.31 -  /// \todo Refer how to specialize it.
    1.32 -
    1.33 +  /// If the graph contains a \e bNodeNum() member function and a 
    1.34 +  /// \e NodeNumTag tag then this function calls directly the member
    1.35 +  /// function to query the cardinality of the B-node set.
    1.36    template <typename Graph>
    1.37    inline int countBNodes(const Graph& g) {
    1.38      return _graph_utils_bits::CountBNodesSelector<Graph>::count(g);
    1.39 @@ -247,7 +250,10 @@
    1.40    /// This function counts the edges in the graph.
    1.41    /// The complexity of the function is O(e) but for some
    1.42    /// graph structures it is specialized to run in O(1).
    1.43 -
    1.44 +  ///
    1.45 +  /// If the graph contains a \e edgeNum() member function and a 
    1.46 +  /// \e EdgeNumTag tag then this function calls directly the member
    1.47 +  /// function to query the cardinality of the edge set.
    1.48    template <typename Graph>
    1.49    inline int countEdges(const Graph& g) {
    1.50      return _graph_utils_bits::CountEdgesSelector<Graph>::count(g);
    1.51 @@ -279,7 +285,10 @@
    1.52    /// This function counts the undirected edges in the graph.
    1.53    /// The complexity of the function is O(e) but for some
    1.54    /// graph structures it is specialized to run in O(1).
    1.55 -
    1.56 +  ///
    1.57 +  /// If the graph contains a \e uEdgeNum() member function and a 
    1.58 +  /// \e EdgeNumTag tag then this function calls directly the member
    1.59 +  /// function to query the cardinality of the undirected edge set.
    1.60    template <typename Graph>
    1.61    inline int countUEdges(const Graph& g) {
    1.62      return _graph_utils_bits::CountUEdgesSelector<Graph>::count(g);
    1.63 @@ -559,26 +568,26 @@
    1.64  
    1.65    /// \brief Copy a map.
    1.66    ///
    1.67 -  /// This function copies the \c source map to the \c target map. It uses the
    1.68 +  /// This function copies the \c from map to the \c to map. It uses the
    1.69    /// given iterator to iterate on the data structure and it uses the \c ref
    1.70 -  /// mapping to convert the source's keys to the target's keys.
    1.71 -  template <typename Target, typename Source, 
    1.72 +  /// mapping to convert the from's keys to the to's keys.
    1.73 +  template <typename To, typename From, 
    1.74  	    typename ItemIt, typename Ref>	    
    1.75 -  void copyMap(Target& target, const Source& source, 
    1.76 +  void copyMap(To& to, const From& from, 
    1.77  	       ItemIt it, const Ref& ref) {
    1.78      for (; it != INVALID; ++it) {
    1.79 -      target[ref[it]] = source[it];
    1.80 +      to[ref[it]] = from[it];
    1.81      }
    1.82    }
    1.83  
    1.84 -  /// \brief Copy the source map to the target map.
    1.85 +  /// \brief Copy the from map to the to map.
    1.86    ///
    1.87 -  /// Copy the \c source map to the \c target map. It uses the given iterator
    1.88 +  /// Copy the \c from map to the \c to map. It uses the given iterator
    1.89    /// to iterate on the data structure.
    1.90 -  template <typename Target, typename Source, typename ItemIt>	    
    1.91 -  void copyMap(Target& target, const Source& source, ItemIt it) {
    1.92 +  template <typename To, typename From, typename ItemIt>	    
    1.93 +  void copyMap(To& to, const From& from, ItemIt it) {
    1.94      for (; it != INVALID; ++it) {
    1.95 -      target[it] = source[it];
    1.96 +      to[it] = from[it];
    1.97      }
    1.98    }
    1.99  
   1.100 @@ -587,17 +596,17 @@
   1.101      template <typename Graph, typename Item, typename RefMap>
   1.102      class MapCopyBase {
   1.103      public:
   1.104 -      virtual void copy(const Graph& source, const RefMap& refMap) = 0;
   1.105 +      virtual void copy(const Graph& from, const RefMap& refMap) = 0;
   1.106        
   1.107        virtual ~MapCopyBase() {}
   1.108      };
   1.109  
   1.110      template <typename Graph, typename Item, typename RefMap, 
   1.111 -              typename TargetMap, typename SourceMap>
   1.112 +              typename ToMap, typename FromMap>
   1.113      class MapCopy : public MapCopyBase<Graph, Item, RefMap> {
   1.114      public:
   1.115  
   1.116 -      MapCopy(TargetMap& tmap, const SourceMap& map) 
   1.117 +      MapCopy(ToMap& tmap, const FromMap& map) 
   1.118          : _tmap(tmap), _map(map) {}
   1.119        
   1.120        virtual void copy(const Graph& graph, const RefMap& refMap) {
   1.121 @@ -608,8 +617,8 @@
   1.122        }
   1.123  
   1.124      private:
   1.125 -      TargetMap& _tmap;
   1.126 -      const SourceMap& _map;
   1.127 +      ToMap& _tmap;
   1.128 +      const FromMap& _map;
   1.129      };
   1.130  
   1.131      template <typename Graph, typename Item, typename RefMap, typename It>
   1.132 @@ -664,15 +673,15 @@
   1.133  
   1.134      template <typename Graph, typename Enable = void>
   1.135      struct GraphCopySelector {
   1.136 -      template <typename Source, typename NodeRefMap, typename EdgeRefMap>
   1.137 -      static void copy(Graph &target, const Source& source,
   1.138 +      template <typename From, typename NodeRefMap, typename EdgeRefMap>
   1.139 +      static void copy(Graph &to, const From& from,
   1.140                         NodeRefMap& nodeRefMap, EdgeRefMap& edgeRefMap) {
   1.141 -        for (typename Source::NodeIt it(source); it != INVALID; ++it) {
   1.142 -          nodeRefMap[it] = target.addNode();
   1.143 +        for (typename From::NodeIt it(from); it != INVALID; ++it) {
   1.144 +          nodeRefMap[it] = to.addNode();
   1.145          }
   1.146 -        for (typename Source::EdgeIt it(source); it != INVALID; ++it) {
   1.147 -          edgeRefMap[it] = target.addEdge(nodeRefMap[source.source(it)], 
   1.148 -                                          nodeRefMap[source.target(it)]);
   1.149 +        for (typename From::EdgeIt it(from); it != INVALID; ++it) {
   1.150 +          edgeRefMap[it] = to.addEdge(nodeRefMap[from.source(it)], 
   1.151 +                                          nodeRefMap[from.target(it)]);
   1.152          }
   1.153        }
   1.154      };
   1.155 @@ -682,24 +691,24 @@
   1.156        Graph, 
   1.157        typename enable_if<typename Graph::BuildTag, void>::type> 
   1.158      {
   1.159 -      template <typename Source, typename NodeRefMap, typename EdgeRefMap>
   1.160 -      static void copy(Graph &target, const Source& source,
   1.161 +      template <typename From, typename NodeRefMap, typename EdgeRefMap>
   1.162 +      static void copy(Graph &to, const From& from,
   1.163                         NodeRefMap& nodeRefMap, EdgeRefMap& edgeRefMap) {
   1.164 -        target.build(source, nodeRefMap, edgeRefMap);
   1.165 +        to.build(from, nodeRefMap, edgeRefMap);
   1.166        }
   1.167      };
   1.168  
   1.169      template <typename UGraph, typename Enable = void>
   1.170      struct UGraphCopySelector {
   1.171 -      template <typename Source, typename NodeRefMap, typename UEdgeRefMap>
   1.172 -      static void copy(UGraph &target, const Source& source,
   1.173 +      template <typename From, typename NodeRefMap, typename UEdgeRefMap>
   1.174 +      static void copy(UGraph &to, const From& from,
   1.175                         NodeRefMap& nodeRefMap, UEdgeRefMap& uEdgeRefMap) {
   1.176 -        for (typename Source::NodeIt it(source); it != INVALID; ++it) {
   1.177 -          nodeRefMap[it] = target.addNode();
   1.178 +        for (typename From::NodeIt it(from); it != INVALID; ++it) {
   1.179 +          nodeRefMap[it] = to.addNode();
   1.180          }
   1.181 -        for (typename Source::UEdgeIt it(source); it != INVALID; ++it) {
   1.182 -          uEdgeRefMap[it] = target.addEdge(nodeRefMap[source.source(it)], 
   1.183 -                                          nodeRefMap[source.target(it)]);
   1.184 +        for (typename From::UEdgeIt it(from); it != INVALID; ++it) {
   1.185 +          uEdgeRefMap[it] = to.addEdge(nodeRefMap[from.source(it)], 
   1.186 +				       nodeRefMap[from.target(it)]);
   1.187          }
   1.188        }
   1.189      };
   1.190 @@ -709,29 +718,29 @@
   1.191        UGraph, 
   1.192        typename enable_if<typename UGraph::BuildTag, void>::type> 
   1.193      {
   1.194 -      template <typename Source, typename NodeRefMap, typename UEdgeRefMap>
   1.195 -      static void copy(UGraph &target, const Source& source,
   1.196 +      template <typename From, typename NodeRefMap, typename UEdgeRefMap>
   1.197 +      static void copy(UGraph &to, const From& from,
   1.198                         NodeRefMap& nodeRefMap, UEdgeRefMap& uEdgeRefMap) {
   1.199 -        target.build(source, nodeRefMap, uEdgeRefMap);
   1.200 +        to.build(from, nodeRefMap, uEdgeRefMap);
   1.201        }
   1.202      };
   1.203  
   1.204      template <typename BpUGraph, typename Enable = void>
   1.205      struct BpUGraphCopySelector {
   1.206 -      template <typename Source, typename ANodeRefMap, 
   1.207 +      template <typename From, typename ANodeRefMap, 
   1.208                  typename BNodeRefMap, typename UEdgeRefMap>
   1.209 -      static void copy(BpUGraph &target, const Source& source,
   1.210 +      static void copy(BpUGraph &to, const From& from,
   1.211                         ANodeRefMap& aNodeRefMap, BNodeRefMap& bNodeRefMap,
   1.212                         UEdgeRefMap& uEdgeRefMap) {
   1.213 -        for (typename Source::ANodeIt it(source); it != INVALID; ++it) {
   1.214 -          aNodeRefMap[it] = target.addANode();
   1.215 +        for (typename From::ANodeIt it(from); it != INVALID; ++it) {
   1.216 +          aNodeRefMap[it] = to.addANode();
   1.217          }
   1.218 -        for (typename Source::BNodeIt it(source); it != INVALID; ++it) {
   1.219 -          bNodeRefMap[it] = target.addBNode();
   1.220 +        for (typename From::BNodeIt it(from); it != INVALID; ++it) {
   1.221 +          bNodeRefMap[it] = to.addBNode();
   1.222          }
   1.223 -        for (typename Source::UEdgeIt it(source); it != INVALID; ++it) {
   1.224 -          uEdgeRefMap[it] = target.addEdge(aNodeRefMap[source.aNode(it)], 
   1.225 -                                           bNodeRefMap[source.bNode(it)]);
   1.226 +        for (typename From::UEdgeIt it(from); it != INVALID; ++it) {
   1.227 +          uEdgeRefMap[it] = to.addEdge(aNodeRefMap[from.aNode(it)], 
   1.228 +                                           bNodeRefMap[from.bNode(it)]);
   1.229          }
   1.230        }
   1.231      };
   1.232 @@ -741,12 +750,12 @@
   1.233        BpUGraph, 
   1.234        typename enable_if<typename BpUGraph::BuildTag, void>::type> 
   1.235      {
   1.236 -      template <typename Source, typename ANodeRefMap, 
   1.237 +      template <typename From, typename ANodeRefMap, 
   1.238                  typename BNodeRefMap, typename UEdgeRefMap>
   1.239 -      static void copy(BpUGraph &target, const Source& source,
   1.240 +      static void copy(BpUGraph &to, const From& from,
   1.241                         ANodeRefMap& aNodeRefMap, BNodeRefMap& bNodeRefMap,
   1.242                         UEdgeRefMap& uEdgeRefMap) {
   1.243 -        target.build(source, aNodeRefMap, bNodeRefMap, uEdgeRefMap);
   1.244 +        to.build(from, aNodeRefMap, bNodeRefMap, uEdgeRefMap);
   1.245        }
   1.246      };
   1.247      
   1.248 @@ -757,20 +766,20 @@
   1.249    ///
   1.250    /// Class to copy a graph to another graph (duplicate a graph). The
   1.251    /// simplest way of using it is through the \c copyGraph() function.
   1.252 -  template <typename Target, typename Source>
   1.253 +  template <typename To, typename From>
   1.254    class GraphCopy {
   1.255    private:
   1.256  
   1.257 -    typedef typename Source::Node Node;
   1.258 -    typedef typename Source::NodeIt NodeIt;
   1.259 -    typedef typename Source::Edge Edge;
   1.260 -    typedef typename Source::EdgeIt EdgeIt;
   1.261 +    typedef typename From::Node Node;
   1.262 +    typedef typename From::NodeIt NodeIt;
   1.263 +    typedef typename From::Edge Edge;
   1.264 +    typedef typename From::EdgeIt EdgeIt;
   1.265  
   1.266 -    typedef typename Target::Node TNode;
   1.267 -    typedef typename Target::Edge TEdge;
   1.268 +    typedef typename To::Node TNode;
   1.269 +    typedef typename To::Edge TEdge;
   1.270  
   1.271 -    typedef typename Source::template NodeMap<TNode> NodeRefMap;
   1.272 -    typedef typename Source::template EdgeMap<TEdge> EdgeRefMap;
   1.273 +    typedef typename From::template NodeMap<TNode> NodeRefMap;
   1.274 +    typedef typename From::template EdgeMap<TEdge> EdgeRefMap;
   1.275      
   1.276      
   1.277    public: 
   1.278 @@ -778,10 +787,10 @@
   1.279  
   1.280      /// \brief Constructor for the GraphCopy.
   1.281      ///
   1.282 -    /// It copies the content of the \c _source graph into the
   1.283 -    /// \c _target graph.
   1.284 -    GraphCopy(Target& _target, const Source& _source) 
   1.285 -      : source(_source), target(_target) {}
   1.286 +    /// It copies the content of the \c _from graph into the
   1.287 +    /// \c _to graph.
   1.288 +    GraphCopy(To& _to, const From& _from) 
   1.289 +      : from(_from), to(_to) {}
   1.290  
   1.291      /// \brief Destructor of the GraphCopy
   1.292      ///
   1.293 @@ -801,7 +810,7 @@
   1.294      /// Copies the node references into the given map.
   1.295      template <typename NodeRef>
   1.296      GraphCopy& nodeRef(NodeRef& map) {
   1.297 -      nodeMapCopies.push_back(new _graph_utils_bits::RefCopy<Source, Node, 
   1.298 +      nodeMapCopies.push_back(new _graph_utils_bits::RefCopy<From, Node, 
   1.299                                NodeRefMap, NodeRef>(map));
   1.300        return *this;
   1.301      }
   1.302 @@ -812,7 +821,7 @@
   1.303      ///  the given map.
   1.304      template <typename NodeCrossRef>
   1.305      GraphCopy& nodeCrossRef(NodeCrossRef& map) {
   1.306 -      nodeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<Source, Node,
   1.307 +      nodeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<From, Node,
   1.308                                NodeRefMap, NodeCrossRef>(map));
   1.309        return *this;
   1.310      }
   1.311 @@ -820,13 +829,13 @@
   1.312      /// \brief Make copy of the given map.
   1.313      ///
   1.314      /// Makes copy of the given map for the newly created graph. 
   1.315 -    /// The new map's key type is the target graph's node type,
   1.316 -    /// and the copied map's key type is the source graph's node
   1.317 +    /// The new map's key type is the to graph's node type,
   1.318 +    /// and the copied map's key type is the from graph's node
   1.319      /// type.  
   1.320 -    template <typename TargetMap, typename SourceMap>
   1.321 -    GraphCopy& nodeMap(TargetMap& tmap, const SourceMap& map) {
   1.322 -      nodeMapCopies.push_back(new _graph_utils_bits::MapCopy<Source, Node, 
   1.323 -                              NodeRefMap, TargetMap, SourceMap>(tmap, map));
   1.324 +    template <typename ToMap, typename FromMap>
   1.325 +    GraphCopy& nodeMap(ToMap& tmap, const FromMap& map) {
   1.326 +      nodeMapCopies.push_back(new _graph_utils_bits::MapCopy<From, Node, 
   1.327 +                              NodeRefMap, ToMap, FromMap>(tmap, map));
   1.328        return *this;
   1.329      }
   1.330  
   1.331 @@ -834,7 +843,7 @@
   1.332      ///
   1.333      /// Make a copy of the given node.
   1.334      GraphCopy& node(TNode& tnode, const Node& snode) {
   1.335 -      nodeMapCopies.push_back(new _graph_utils_bits::ItemCopy<Source, Node, 
   1.336 +      nodeMapCopies.push_back(new _graph_utils_bits::ItemCopy<From, Node, 
   1.337                                NodeRefMap, TNode>(tnode, snode));
   1.338        return *this;
   1.339      }
   1.340 @@ -844,7 +853,7 @@
   1.341      /// Copies the edge references into the given map.
   1.342      template <typename EdgeRef>
   1.343      GraphCopy& edgeRef(EdgeRef& map) {
   1.344 -      edgeMapCopies.push_back(new _graph_utils_bits::RefCopy<Source, Edge, 
   1.345 +      edgeMapCopies.push_back(new _graph_utils_bits::RefCopy<From, Edge, 
   1.346                                EdgeRefMap, EdgeRef>(map));
   1.347        return *this;
   1.348      }
   1.349 @@ -855,7 +864,7 @@
   1.350      ///  the given map.
   1.351      template <typename EdgeCrossRef>
   1.352      GraphCopy& edgeCrossRef(EdgeCrossRef& map) {
   1.353 -      edgeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<Source, Edge,
   1.354 +      edgeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<From, Edge,
   1.355                                EdgeRefMap, EdgeCrossRef>(map));
   1.356        return *this;
   1.357      }
   1.358 @@ -863,13 +872,13 @@
   1.359      /// \brief Make copy of the given map.
   1.360      ///
   1.361      /// Makes copy of the given map for the newly created graph. 
   1.362 -    /// The new map's key type is the target graph's edge type,
   1.363 -    /// and the copied map's key type is the source graph's edge
   1.364 +    /// The new map's key type is the to graph's edge type,
   1.365 +    /// and the copied map's key type is the from graph's edge
   1.366      /// type.  
   1.367 -    template <typename TargetMap, typename SourceMap>
   1.368 -    GraphCopy& edgeMap(TargetMap& tmap, const SourceMap& map) {
   1.369 -      edgeMapCopies.push_back(new _graph_utils_bits::MapCopy<Source, Edge, 
   1.370 -                              EdgeRefMap, TargetMap, SourceMap>(tmap, map));
   1.371 +    template <typename ToMap, typename FromMap>
   1.372 +    GraphCopy& edgeMap(ToMap& tmap, const FromMap& map) {
   1.373 +      edgeMapCopies.push_back(new _graph_utils_bits::MapCopy<From, Edge, 
   1.374 +                              EdgeRefMap, ToMap, FromMap>(tmap, map));
   1.375        return *this;
   1.376      }
   1.377  
   1.378 @@ -877,7 +886,7 @@
   1.379      ///
   1.380      /// Make a copy of the given edge.
   1.381      GraphCopy& edge(TEdge& tedge, const Edge& sedge) {
   1.382 -      edgeMapCopies.push_back(new _graph_utils_bits::ItemCopy<Source, Edge, 
   1.383 +      edgeMapCopies.push_back(new _graph_utils_bits::ItemCopy<From, Edge, 
   1.384                                EdgeRefMap, TEdge>(tedge, sedge));
   1.385        return *this;
   1.386      }
   1.387 @@ -886,28 +895,28 @@
   1.388      ///
   1.389      /// Executes the copies.
   1.390      void run() {
   1.391 -      NodeRefMap nodeRefMap(source);
   1.392 -      EdgeRefMap edgeRefMap(source);
   1.393 -      _graph_utils_bits::GraphCopySelector<Target>::
   1.394 -        copy(target, source, nodeRefMap, edgeRefMap);
   1.395 +      NodeRefMap nodeRefMap(from);
   1.396 +      EdgeRefMap edgeRefMap(from);
   1.397 +      _graph_utils_bits::GraphCopySelector<To>::
   1.398 +        copy(to, from, nodeRefMap, edgeRefMap);
   1.399        for (int i = 0; i < int(nodeMapCopies.size()); ++i) {
   1.400 -        nodeMapCopies[i]->copy(source, nodeRefMap);
   1.401 +        nodeMapCopies[i]->copy(from, nodeRefMap);
   1.402        }
   1.403        for (int i = 0; i < int(edgeMapCopies.size()); ++i) {
   1.404 -        edgeMapCopies[i]->copy(source, edgeRefMap);
   1.405 +        edgeMapCopies[i]->copy(from, edgeRefMap);
   1.406        }      
   1.407      }
   1.408  
   1.409    protected:
   1.410  
   1.411  
   1.412 -    const Source& source;
   1.413 -    Target& target;
   1.414 +    const From& from;
   1.415 +    To& to;
   1.416  
   1.417 -    std::vector<_graph_utils_bits::MapCopyBase<Source, Node, NodeRefMap>* > 
   1.418 +    std::vector<_graph_utils_bits::MapCopyBase<From, Node, NodeRefMap>* > 
   1.419      nodeMapCopies;
   1.420  
   1.421 -    std::vector<_graph_utils_bits::MapCopyBase<Source, Edge, EdgeRefMap>* > 
   1.422 +    std::vector<_graph_utils_bits::MapCopyBase<From, Edge, EdgeRefMap>* > 
   1.423      edgeMapCopies;
   1.424  
   1.425    };
   1.426 @@ -922,57 +931,57 @@
   1.427    ///\endcode
   1.428    /// 
   1.429    /// After the copy the \c nr map will contain the mapping from the
   1.430 -  /// source graph's nodes to the target graph's nodes and the \c ecr will
   1.431 -  /// contain the mapping from the target graph's edges to the source's
   1.432 +  /// from graph's nodes to the to graph's nodes and the \c ecr will
   1.433 +  /// contain the mapping from the to graph's edges to the from's
   1.434    /// edges.
   1.435    ///
   1.436    /// \see GraphCopy 
   1.437 -  template <typename Target, typename Source>
   1.438 -  GraphCopy<Target, Source> copyGraph(Target& target, const Source& source) {
   1.439 -    return GraphCopy<Target, Source>(target, source);
   1.440 +  template <typename To, typename From>
   1.441 +  GraphCopy<To, From> copyGraph(To& to, const From& from) {
   1.442 +    return GraphCopy<To, From>(to, from);
   1.443    }
   1.444  
   1.445    /// \brief Class to copy an undirected graph.
   1.446    ///
   1.447    /// Class to copy an undirected graph to another graph (duplicate a graph).
   1.448    /// The simplest way of using it is through the \c copyUGraph() function.
   1.449 -  template <typename Target, typename Source>
   1.450 +  template <typename To, typename From>
   1.451    class UGraphCopy {
   1.452    private:
   1.453  
   1.454 -    typedef typename Source::Node Node;
   1.455 -    typedef typename Source::NodeIt NodeIt;
   1.456 -    typedef typename Source::Edge Edge;
   1.457 -    typedef typename Source::EdgeIt EdgeIt;
   1.458 -    typedef typename Source::UEdge UEdge;
   1.459 -    typedef typename Source::UEdgeIt UEdgeIt;
   1.460 +    typedef typename From::Node Node;
   1.461 +    typedef typename From::NodeIt NodeIt;
   1.462 +    typedef typename From::Edge Edge;
   1.463 +    typedef typename From::EdgeIt EdgeIt;
   1.464 +    typedef typename From::UEdge UEdge;
   1.465 +    typedef typename From::UEdgeIt UEdgeIt;
   1.466  
   1.467 -    typedef typename Target::Node TNode;
   1.468 -    typedef typename Target::Edge TEdge;
   1.469 -    typedef typename Target::UEdge TUEdge;
   1.470 +    typedef typename To::Node TNode;
   1.471 +    typedef typename To::Edge TEdge;
   1.472 +    typedef typename To::UEdge TUEdge;
   1.473  
   1.474 -    typedef typename Source::template NodeMap<TNode> NodeRefMap;
   1.475 -    typedef typename Source::template UEdgeMap<TUEdge> UEdgeRefMap;
   1.476 +    typedef typename From::template NodeMap<TNode> NodeRefMap;
   1.477 +    typedef typename From::template UEdgeMap<TUEdge> UEdgeRefMap;
   1.478  
   1.479      struct EdgeRefMap {
   1.480 -      EdgeRefMap(const Target& _target, const Source& _source,
   1.481 +      EdgeRefMap(const To& _to, const From& _from,
   1.482                   const UEdgeRefMap& _uedge_ref, const NodeRefMap& _node_ref) 
   1.483 -        : target(_target), source(_source), 
   1.484 +        : to(_to), from(_from), 
   1.485            uedge_ref(_uedge_ref), node_ref(_node_ref) {}
   1.486  
   1.487 -      typedef typename Source::Edge Key;
   1.488 -      typedef typename Target::Edge Value;
   1.489 +      typedef typename From::Edge Key;
   1.490 +      typedef typename To::Edge Value;
   1.491  
   1.492        Value operator[](const Key& key) const {
   1.493          bool forward = 
   1.494 -          (source.direction(key) == 
   1.495 -           (node_ref[source.source(static_cast<const UEdge&>(key))] == 
   1.496 -            target.source(uedge_ref[static_cast<const UEdge&>(key)])));
   1.497 -	return target.direct(uedge_ref[key], forward); 
   1.498 +          (from.direction(key) == 
   1.499 +           (node_ref[from.source(static_cast<const UEdge&>(key))] == 
   1.500 +            to.source(uedge_ref[static_cast<const UEdge&>(key)])));
   1.501 +	return to.direct(uedge_ref[key], forward); 
   1.502        }
   1.503        
   1.504 -      const Target& target;
   1.505 -      const Source& source;
   1.506 +      const To& to;
   1.507 +      const From& from;
   1.508        const UEdgeRefMap& uedge_ref;
   1.509        const NodeRefMap& node_ref;
   1.510      };
   1.511 @@ -983,10 +992,10 @@
   1.512  
   1.513      /// \brief Constructor for the GraphCopy.
   1.514      ///
   1.515 -    /// It copies the content of the \c _source graph into the
   1.516 -    /// \c _target graph.
   1.517 -    UGraphCopy(Target& _target, const Source& _source) 
   1.518 -      : source(_source), target(_target) {}
   1.519 +    /// It copies the content of the \c _from graph into the
   1.520 +    /// \c _to graph.
   1.521 +    UGraphCopy(To& _to, const From& _from) 
   1.522 +      : from(_from), to(_to) {}
   1.523  
   1.524      /// \brief Destructor of the GraphCopy
   1.525      ///
   1.526 @@ -1009,7 +1018,7 @@
   1.527      /// Copies the node references into the given map.
   1.528      template <typename NodeRef>
   1.529      UGraphCopy& nodeRef(NodeRef& map) {
   1.530 -      nodeMapCopies.push_back(new _graph_utils_bits::RefCopy<Source, Node, 
   1.531 +      nodeMapCopies.push_back(new _graph_utils_bits::RefCopy<From, Node, 
   1.532                                NodeRefMap, NodeRef>(map));
   1.533        return *this;
   1.534      }
   1.535 @@ -1020,7 +1029,7 @@
   1.536      ///  the given map.
   1.537      template <typename NodeCrossRef>
   1.538      UGraphCopy& nodeCrossRef(NodeCrossRef& map) {
   1.539 -      nodeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<Source, Node,
   1.540 +      nodeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<From, Node,
   1.541                                NodeRefMap, NodeCrossRef>(map));
   1.542        return *this;
   1.543      }
   1.544 @@ -1028,13 +1037,13 @@
   1.545      /// \brief Make copy of the given map.
   1.546      ///
   1.547      /// Makes copy of the given map for the newly created graph. 
   1.548 -    /// The new map's key type is the target graph's node type,
   1.549 -    /// and the copied map's key type is the source graph's node
   1.550 +    /// The new map's key type is the to graph's node type,
   1.551 +    /// and the copied map's key type is the from graph's node
   1.552      /// type.  
   1.553 -    template <typename TargetMap, typename SourceMap>
   1.554 -    UGraphCopy& nodeMap(TargetMap& tmap, const SourceMap& map) {
   1.555 -      nodeMapCopies.push_back(new _graph_utils_bits::MapCopy<Source, Node, 
   1.556 -                              NodeRefMap, TargetMap, SourceMap>(tmap, map));
   1.557 +    template <typename ToMap, typename FromMap>
   1.558 +    UGraphCopy& nodeMap(ToMap& tmap, const FromMap& map) {
   1.559 +      nodeMapCopies.push_back(new _graph_utils_bits::MapCopy<From, Node, 
   1.560 +                              NodeRefMap, ToMap, FromMap>(tmap, map));
   1.561        return *this;
   1.562      }
   1.563  
   1.564 @@ -1042,7 +1051,7 @@
   1.565      ///
   1.566      /// Make a copy of the given node.
   1.567      UGraphCopy& node(TNode& tnode, const Node& snode) {
   1.568 -      nodeMapCopies.push_back(new _graph_utils_bits::ItemCopy<Source, Node, 
   1.569 +      nodeMapCopies.push_back(new _graph_utils_bits::ItemCopy<From, Node, 
   1.570                                NodeRefMap, TNode>(tnode, snode));
   1.571        return *this;
   1.572      }
   1.573 @@ -1052,7 +1061,7 @@
   1.574      /// Copies the edge references into the given map.
   1.575      template <typename EdgeRef>
   1.576      UGraphCopy& edgeRef(EdgeRef& map) {
   1.577 -      edgeMapCopies.push_back(new _graph_utils_bits::RefCopy<Source, Edge, 
   1.578 +      edgeMapCopies.push_back(new _graph_utils_bits::RefCopy<From, Edge, 
   1.579                                EdgeRefMap, EdgeRef>(map));
   1.580        return *this;
   1.581      }
   1.582 @@ -1063,7 +1072,7 @@
   1.583      ///  the given map.
   1.584      template <typename EdgeCrossRef>
   1.585      UGraphCopy& edgeCrossRef(EdgeCrossRef& map) {
   1.586 -      edgeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<Source, Edge,
   1.587 +      edgeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<From, Edge,
   1.588                                EdgeRefMap, EdgeCrossRef>(map));
   1.589        return *this;
   1.590      }
   1.591 @@ -1071,13 +1080,13 @@
   1.592      /// \brief Make copy of the given map.
   1.593      ///
   1.594      /// Makes copy of the given map for the newly created graph. 
   1.595 -    /// The new map's key type is the target graph's edge type,
   1.596 -    /// and the copied map's key type is the source graph's edge
   1.597 +    /// The new map's key type is the to graph's edge type,
   1.598 +    /// and the copied map's key type is the from graph's edge
   1.599      /// type.  
   1.600 -    template <typename TargetMap, typename SourceMap>
   1.601 -    UGraphCopy& edgeMap(TargetMap& tmap, const SourceMap& map) {
   1.602 -      edgeMapCopies.push_back(new _graph_utils_bits::MapCopy<Source, Edge, 
   1.603 -                              EdgeRefMap, TargetMap, SourceMap>(tmap, map));
   1.604 +    template <typename ToMap, typename FromMap>
   1.605 +    UGraphCopy& edgeMap(ToMap& tmap, const FromMap& map) {
   1.606 +      edgeMapCopies.push_back(new _graph_utils_bits::MapCopy<From, Edge, 
   1.607 +                              EdgeRefMap, ToMap, FromMap>(tmap, map));
   1.608        return *this;
   1.609      }
   1.610  
   1.611 @@ -1085,7 +1094,7 @@
   1.612      ///
   1.613      /// Make a copy of the given edge.
   1.614      UGraphCopy& edge(TEdge& tedge, const Edge& sedge) {
   1.615 -      edgeMapCopies.push_back(new _graph_utils_bits::ItemCopy<Source, Edge, 
   1.616 +      edgeMapCopies.push_back(new _graph_utils_bits::ItemCopy<From, Edge, 
   1.617                                EdgeRefMap, TEdge>(tedge, sedge));
   1.618        return *this;
   1.619      }
   1.620 @@ -1095,7 +1104,7 @@
   1.621      /// Copies the undirected edge references into the given map.
   1.622      template <typename UEdgeRef>
   1.623      UGraphCopy& uEdgeRef(UEdgeRef& map) {
   1.624 -      uEdgeMapCopies.push_back(new _graph_utils_bits::RefCopy<Source, UEdge, 
   1.625 +      uEdgeMapCopies.push_back(new _graph_utils_bits::RefCopy<From, UEdge, 
   1.626                                 UEdgeRefMap, UEdgeRef>(map));
   1.627        return *this;
   1.628      }
   1.629 @@ -1106,7 +1115,7 @@
   1.630      /// references) into the given map.
   1.631      template <typename UEdgeCrossRef>
   1.632      UGraphCopy& uEdgeCrossRef(UEdgeCrossRef& map) {
   1.633 -      uEdgeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<Source, 
   1.634 +      uEdgeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<From, 
   1.635                                 UEdge, UEdgeRefMap, UEdgeCrossRef>(map));
   1.636        return *this;
   1.637      }
   1.638 @@ -1114,13 +1123,13 @@
   1.639      /// \brief Make copy of the given map.
   1.640      ///
   1.641      /// Makes copy of the given map for the newly created graph. 
   1.642 -    /// The new map's key type is the target graph's undirected edge type,
   1.643 -    /// and the copied map's key type is the source graph's undirected edge
   1.644 +    /// The new map's key type is the to graph's undirected edge type,
   1.645 +    /// and the copied map's key type is the from graph's undirected edge
   1.646      /// type.  
   1.647 -    template <typename TargetMap, typename SourceMap>
   1.648 -    UGraphCopy& uEdgeMap(TargetMap& tmap, const SourceMap& map) {
   1.649 -      uEdgeMapCopies.push_back(new _graph_utils_bits::MapCopy<Source, UEdge, 
   1.650 -                               UEdgeRefMap, TargetMap, SourceMap>(tmap, map));
   1.651 +    template <typename ToMap, typename FromMap>
   1.652 +    UGraphCopy& uEdgeMap(ToMap& tmap, const FromMap& map) {
   1.653 +      uEdgeMapCopies.push_back(new _graph_utils_bits::MapCopy<From, UEdge, 
   1.654 +                               UEdgeRefMap, ToMap, FromMap>(tmap, map));
   1.655        return *this;
   1.656      }
   1.657  
   1.658 @@ -1128,7 +1137,7 @@
   1.659      ///
   1.660      /// Make a copy of the given undirected edge.
   1.661      UGraphCopy& uEdge(TUEdge& tuedge, const UEdge& suedge) {
   1.662 -      uEdgeMapCopies.push_back(new _graph_utils_bits::ItemCopy<Source, UEdge, 
   1.663 +      uEdgeMapCopies.push_back(new _graph_utils_bits::ItemCopy<From, UEdge, 
   1.664                                 UEdgeRefMap, TUEdge>(tuedge, suedge));
   1.665        return *this;
   1.666      }
   1.667 @@ -1137,34 +1146,34 @@
   1.668      ///
   1.669      /// Executes the copies.
   1.670      void run() {
   1.671 -      NodeRefMap nodeRefMap(source);
   1.672 -      UEdgeRefMap uEdgeRefMap(source);
   1.673 -      EdgeRefMap edgeRefMap(target, source, uEdgeRefMap, nodeRefMap);
   1.674 -      _graph_utils_bits::UGraphCopySelector<Target>::
   1.675 -        copy(target, source, nodeRefMap, uEdgeRefMap);
   1.676 +      NodeRefMap nodeRefMap(from);
   1.677 +      UEdgeRefMap uEdgeRefMap(from);
   1.678 +      EdgeRefMap edgeRefMap(to, from, uEdgeRefMap, nodeRefMap);
   1.679 +      _graph_utils_bits::UGraphCopySelector<To>::
   1.680 +        copy(to, from, nodeRefMap, uEdgeRefMap);
   1.681        for (int i = 0; i < int(nodeMapCopies.size()); ++i) {
   1.682 -        nodeMapCopies[i]->copy(source, nodeRefMap);
   1.683 +        nodeMapCopies[i]->copy(from, nodeRefMap);
   1.684        }
   1.685        for (int i = 0; i < int(uEdgeMapCopies.size()); ++i) {
   1.686 -        uEdgeMapCopies[i]->copy(source, uEdgeRefMap);
   1.687 +        uEdgeMapCopies[i]->copy(from, uEdgeRefMap);
   1.688        }
   1.689        for (int i = 0; i < int(edgeMapCopies.size()); ++i) {
   1.690 -        edgeMapCopies[i]->copy(source, edgeRefMap);
   1.691 +        edgeMapCopies[i]->copy(from, edgeRefMap);
   1.692        }
   1.693      }
   1.694  
   1.695    private:
   1.696      
   1.697 -    const Source& source;
   1.698 -    Target& target;
   1.699 +    const From& from;
   1.700 +    To& to;
   1.701  
   1.702 -    std::vector<_graph_utils_bits::MapCopyBase<Source, Node, NodeRefMap>* > 
   1.703 +    std::vector<_graph_utils_bits::MapCopyBase<From, Node, NodeRefMap>* > 
   1.704      nodeMapCopies;
   1.705  
   1.706 -    std::vector<_graph_utils_bits::MapCopyBase<Source, Edge, EdgeRefMap>* > 
   1.707 +    std::vector<_graph_utils_bits::MapCopyBase<From, Edge, EdgeRefMap>* > 
   1.708      edgeMapCopies;
   1.709  
   1.710 -    std::vector<_graph_utils_bits::MapCopyBase<Source, UEdge, UEdgeRefMap>* > 
   1.711 +    std::vector<_graph_utils_bits::MapCopyBase<From, UEdge, UEdgeRefMap>* > 
   1.712      uEdgeMapCopies;
   1.713  
   1.714    };
   1.715 @@ -1179,15 +1188,15 @@
   1.716    ///\endcode
   1.717    /// 
   1.718    /// After the copy the \c nr map will contain the mapping from the
   1.719 -  /// source graph's nodes to the target graph's nodes and the \c ecr will
   1.720 -  /// contain the mapping from the target graph's edges to the source's
   1.721 +  /// from graph's nodes to the to graph's nodes and the \c ecr will
   1.722 +  /// contain the mapping from the to graph's edges to the from's
   1.723    /// edges.
   1.724    ///
   1.725    /// \see UGraphCopy 
   1.726 -  template <typename Target, typename Source>
   1.727 -  UGraphCopy<Target, Source> 
   1.728 -  copyUGraph(Target& target, const Source& source) {
   1.729 -    return UGraphCopy<Target, Source>(target, source);
   1.730 +  template <typename To, typename From>
   1.731 +  UGraphCopy<To, From> 
   1.732 +  copyUGraph(To& to, const From& from) {
   1.733 +    return UGraphCopy<To, From>(to, from);
   1.734    }
   1.735  
   1.736    /// \brief Class to copy a bipartite undirected graph.
   1.737 @@ -1195,63 +1204,63 @@
   1.738    /// Class to copy a bipartite undirected graph to another graph
   1.739    /// (duplicate a graph).  The simplest way of using it is through
   1.740    /// the \c copyBpUGraph() function.
   1.741 -  template <typename Target, typename Source>
   1.742 +  template <typename To, typename From>
   1.743    class BpUGraphCopy {
   1.744    private:
   1.745  
   1.746 -    typedef typename Source::Node Node;
   1.747 -    typedef typename Source::ANode ANode;
   1.748 -    typedef typename Source::BNode BNode;
   1.749 -    typedef typename Source::NodeIt NodeIt;
   1.750 -    typedef typename Source::Edge Edge;
   1.751 -    typedef typename Source::EdgeIt EdgeIt;
   1.752 -    typedef typename Source::UEdge UEdge;
   1.753 -    typedef typename Source::UEdgeIt UEdgeIt;
   1.754 +    typedef typename From::Node Node;
   1.755 +    typedef typename From::ANode ANode;
   1.756 +    typedef typename From::BNode BNode;
   1.757 +    typedef typename From::NodeIt NodeIt;
   1.758 +    typedef typename From::Edge Edge;
   1.759 +    typedef typename From::EdgeIt EdgeIt;
   1.760 +    typedef typename From::UEdge UEdge;
   1.761 +    typedef typename From::UEdgeIt UEdgeIt;
   1.762  
   1.763 -    typedef typename Target::Node TNode;
   1.764 -    typedef typename Target::Edge TEdge;
   1.765 -    typedef typename Target::UEdge TUEdge;
   1.766 +    typedef typename To::Node TNode;
   1.767 +    typedef typename To::Edge TEdge;
   1.768 +    typedef typename To::UEdge TUEdge;
   1.769  
   1.770 -    typedef typename Source::template ANodeMap<TNode> ANodeRefMap;
   1.771 -    typedef typename Source::template BNodeMap<TNode> BNodeRefMap;
   1.772 -    typedef typename Source::template UEdgeMap<TUEdge> UEdgeRefMap;
   1.773 +    typedef typename From::template ANodeMap<TNode> ANodeRefMap;
   1.774 +    typedef typename From::template BNodeMap<TNode> BNodeRefMap;
   1.775 +    typedef typename From::template UEdgeMap<TUEdge> UEdgeRefMap;
   1.776  
   1.777      struct NodeRefMap {
   1.778 -      NodeRefMap(const Source& _source, const ANodeRefMap& _anode_ref,
   1.779 +      NodeRefMap(const From& _from, const ANodeRefMap& _anode_ref,
   1.780                   const BNodeRefMap& _bnode_ref)
   1.781 -        : source(_source), anode_ref(_anode_ref), bnode_ref(_bnode_ref) {}
   1.782 +        : from(_from), anode_ref(_anode_ref), bnode_ref(_bnode_ref) {}
   1.783  
   1.784 -      typedef typename Source::Node Key;
   1.785 -      typedef typename Target::Node Value;
   1.786 +      typedef typename From::Node Key;
   1.787 +      typedef typename To::Node Value;
   1.788  
   1.789        Value operator[](const Key& key) const {
   1.790 -	return source.aNode(key) ? anode_ref[key] : bnode_ref[key]; 
   1.791 +	return from.aNode(key) ? anode_ref[key] : bnode_ref[key]; 
   1.792        }
   1.793        
   1.794 -      const Source& source;
   1.795 +      const From& from;
   1.796        const ANodeRefMap& anode_ref;
   1.797        const BNodeRefMap& bnode_ref;
   1.798      };
   1.799  
   1.800      struct EdgeRefMap {
   1.801 -      EdgeRefMap(const Target& _target, const Source& _source,
   1.802 +      EdgeRefMap(const To& _to, const From& _from,
   1.803                   const UEdgeRefMap& _uedge_ref, const NodeRefMap& _node_ref) 
   1.804 -        : target(_target), source(_source), 
   1.805 +        : to(_to), from(_from), 
   1.806            uedge_ref(_uedge_ref), node_ref(_node_ref) {}
   1.807  
   1.808 -      typedef typename Source::Edge Key;
   1.809 -      typedef typename Target::Edge Value;
   1.810 +      typedef typename From::Edge Key;
   1.811 +      typedef typename To::Edge Value;
   1.812  
   1.813        Value operator[](const Key& key) const {
   1.814          bool forward = 
   1.815 -          (source.direction(key) == 
   1.816 -           (node_ref[source.source(static_cast<const UEdge&>(key))] == 
   1.817 -            target.source(uedge_ref[static_cast<const UEdge&>(key)])));
   1.818 -	return target.direct(uedge_ref[key], forward); 
   1.819 +          (from.direction(key) == 
   1.820 +           (node_ref[from.source(static_cast<const UEdge&>(key))] == 
   1.821 +            to.source(uedge_ref[static_cast<const UEdge&>(key)])));
   1.822 +	return to.direct(uedge_ref[key], forward); 
   1.823        }
   1.824        
   1.825 -      const Target& target;
   1.826 -      const Source& source;
   1.827 +      const To& to;
   1.828 +      const From& from;
   1.829        const UEdgeRefMap& uedge_ref;
   1.830        const NodeRefMap& node_ref;
   1.831      };
   1.832 @@ -1261,10 +1270,10 @@
   1.833  
   1.834      /// \brief Constructor for the GraphCopy.
   1.835      ///
   1.836 -    /// It copies the content of the \c _source graph into the
   1.837 -    /// \c _target graph.
   1.838 -    BpUGraphCopy(Target& _target, const Source& _source) 
   1.839 -      : source(_source), target(_target) {}
   1.840 +    /// It copies the content of the \c _from graph into the
   1.841 +    /// \c _to graph.
   1.842 +    BpUGraphCopy(To& _to, const From& _from) 
   1.843 +      : from(_from), to(_to) {}
   1.844  
   1.845      /// \brief Destructor of the GraphCopy
   1.846      ///
   1.847 @@ -1293,7 +1302,7 @@
   1.848      /// Copies the A-node references into the given map.
   1.849      template <typename ANodeRef>
   1.850      BpUGraphCopy& aNodeRef(ANodeRef& map) {
   1.851 -      aNodeMapCopies.push_back(new _graph_utils_bits::RefCopy<Source, ANode, 
   1.852 +      aNodeMapCopies.push_back(new _graph_utils_bits::RefCopy<From, ANode, 
   1.853                                 ANodeRefMap, ANodeRef>(map));
   1.854        return *this;
   1.855      }
   1.856 @@ -1304,7 +1313,7 @@
   1.857      /// the given map.
   1.858      template <typename ANodeCrossRef>
   1.859      BpUGraphCopy& aNodeCrossRef(ANodeCrossRef& map) {
   1.860 -      aNodeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<Source, 
   1.861 +      aNodeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<From, 
   1.862                                 ANode, ANodeRefMap, ANodeCrossRef>(map));
   1.863        return *this;
   1.864      }
   1.865 @@ -1312,13 +1321,13 @@
   1.866      /// \brief Make copy of the given A-node map.
   1.867      ///
   1.868      /// Makes copy of the given map for the newly created graph. 
   1.869 -    /// The new map's key type is the target graph's node type,
   1.870 -    /// and the copied map's key type is the source graph's node
   1.871 +    /// The new map's key type is the to graph's node type,
   1.872 +    /// and the copied map's key type is the from graph's node
   1.873      /// type.  
   1.874 -    template <typename TargetMap, typename SourceMap>
   1.875 -    BpUGraphCopy& aNodeMap(TargetMap& tmap, const SourceMap& map) {
   1.876 -      aNodeMapCopies.push_back(new _graph_utils_bits::MapCopy<Source, ANode, 
   1.877 -                               ANodeRefMap, TargetMap, SourceMap>(tmap, map));
   1.878 +    template <typename ToMap, typename FromMap>
   1.879 +    BpUGraphCopy& aNodeMap(ToMap& tmap, const FromMap& map) {
   1.880 +      aNodeMapCopies.push_back(new _graph_utils_bits::MapCopy<From, ANode, 
   1.881 +                               ANodeRefMap, ToMap, FromMap>(tmap, map));
   1.882        return *this;
   1.883      }
   1.884  
   1.885 @@ -1327,7 +1336,7 @@
   1.886      /// Copies the B-node references into the given map.
   1.887      template <typename BNodeRef>
   1.888      BpUGraphCopy& bNodeRef(BNodeRef& map) {
   1.889 -      bNodeMapCopies.push_back(new _graph_utils_bits::RefCopy<Source, BNode, 
   1.890 +      bNodeMapCopies.push_back(new _graph_utils_bits::RefCopy<From, BNode, 
   1.891                                 BNodeRefMap, BNodeRef>(map));
   1.892        return *this;
   1.893      }
   1.894 @@ -1338,7 +1347,7 @@
   1.895      ///  the given map.
   1.896      template <typename BNodeCrossRef>
   1.897      BpUGraphCopy& bNodeCrossRef(BNodeCrossRef& map) {
   1.898 -      bNodeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<Source, 
   1.899 +      bNodeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<From, 
   1.900                                BNode, BNodeRefMap, BNodeCrossRef>(map));
   1.901        return *this;
   1.902      }
   1.903 @@ -1346,13 +1355,13 @@
   1.904      /// \brief Make copy of the given B-node map.
   1.905      ///
   1.906      /// Makes copy of the given map for the newly created graph. 
   1.907 -    /// The new map's key type is the target graph's node type,
   1.908 -    /// and the copied map's key type is the source graph's node
   1.909 +    /// The new map's key type is the to graph's node type,
   1.910 +    /// and the copied map's key type is the from graph's node
   1.911      /// type.  
   1.912 -    template <typename TargetMap, typename SourceMap>
   1.913 -    BpUGraphCopy& bNodeMap(TargetMap& tmap, const SourceMap& map) {
   1.914 -      bNodeMapCopies.push_back(new _graph_utils_bits::MapCopy<Source, BNode, 
   1.915 -                               BNodeRefMap, TargetMap, SourceMap>(tmap, map));
   1.916 +    template <typename ToMap, typename FromMap>
   1.917 +    BpUGraphCopy& bNodeMap(ToMap& tmap, const FromMap& map) {
   1.918 +      bNodeMapCopies.push_back(new _graph_utils_bits::MapCopy<From, BNode, 
   1.919 +                               BNodeRefMap, ToMap, FromMap>(tmap, map));
   1.920        return *this;
   1.921      }
   1.922      /// \brief Copies the node references into the given map.
   1.923 @@ -1360,7 +1369,7 @@
   1.924      /// Copies the node references into the given map.
   1.925      template <typename NodeRef>
   1.926      BpUGraphCopy& nodeRef(NodeRef& map) {
   1.927 -      nodeMapCopies.push_back(new _graph_utils_bits::RefCopy<Source, Node, 
   1.928 +      nodeMapCopies.push_back(new _graph_utils_bits::RefCopy<From, Node, 
   1.929                                NodeRefMap, NodeRef>(map));
   1.930        return *this;
   1.931      }
   1.932 @@ -1371,7 +1380,7 @@
   1.933      ///  the given map.
   1.934      template <typename NodeCrossRef>
   1.935      BpUGraphCopy& nodeCrossRef(NodeCrossRef& map) {
   1.936 -      nodeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<Source, Node,
   1.937 +      nodeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<From, Node,
   1.938                                NodeRefMap, NodeCrossRef>(map));
   1.939        return *this;
   1.940      }
   1.941 @@ -1379,13 +1388,13 @@
   1.942      /// \brief Make copy of the given map.
   1.943      ///
   1.944      /// Makes copy of the given map for the newly created graph. 
   1.945 -    /// The new map's key type is the target graph's node type,
   1.946 -    /// and the copied map's key type is the source graph's node
   1.947 +    /// The new map's key type is the to graph's node type,
   1.948 +    /// and the copied map's key type is the from graph's node
   1.949      /// type.  
   1.950 -    template <typename TargetMap, typename SourceMap>
   1.951 -    BpUGraphCopy& nodeMap(TargetMap& tmap, const SourceMap& map) {
   1.952 -      nodeMapCopies.push_back(new _graph_utils_bits::MapCopy<Source, Node, 
   1.953 -                              NodeRefMap, TargetMap, SourceMap>(tmap, map));
   1.954 +    template <typename ToMap, typename FromMap>
   1.955 +    BpUGraphCopy& nodeMap(ToMap& tmap, const FromMap& map) {
   1.956 +      nodeMapCopies.push_back(new _graph_utils_bits::MapCopy<From, Node, 
   1.957 +                              NodeRefMap, ToMap, FromMap>(tmap, map));
   1.958        return *this;
   1.959      }
   1.960  
   1.961 @@ -1393,7 +1402,7 @@
   1.962      ///
   1.963      /// Make a copy of the given node.
   1.964      BpUGraphCopy& node(TNode& tnode, const Node& snode) {
   1.965 -      nodeMapCopies.push_back(new _graph_utils_bits::ItemCopy<Source, Node, 
   1.966 +      nodeMapCopies.push_back(new _graph_utils_bits::ItemCopy<From, Node, 
   1.967                                NodeRefMap, TNode>(tnode, snode));
   1.968        return *this;
   1.969      }
   1.970 @@ -1403,7 +1412,7 @@
   1.971      /// Copies the edge references into the given map.
   1.972      template <typename EdgeRef>
   1.973      BpUGraphCopy& edgeRef(EdgeRef& map) {
   1.974 -      edgeMapCopies.push_back(new _graph_utils_bits::RefCopy<Source, Edge, 
   1.975 +      edgeMapCopies.push_back(new _graph_utils_bits::RefCopy<From, Edge, 
   1.976                                EdgeRefMap, EdgeRef>(map));
   1.977        return *this;
   1.978      }
   1.979 @@ -1414,7 +1423,7 @@
   1.980      ///  the given map.
   1.981      template <typename EdgeCrossRef>
   1.982      BpUGraphCopy& edgeCrossRef(EdgeCrossRef& map) {
   1.983 -      edgeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<Source, Edge,
   1.984 +      edgeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<From, Edge,
   1.985                                EdgeRefMap, EdgeCrossRef>(map));
   1.986        return *this;
   1.987      }
   1.988 @@ -1422,13 +1431,13 @@
   1.989      /// \brief Make copy of the given map.
   1.990      ///
   1.991      /// Makes copy of the given map for the newly created graph. 
   1.992 -    /// The new map's key type is the target graph's edge type,
   1.993 -    /// and the copied map's key type is the source graph's edge
   1.994 +    /// The new map's key type is the to graph's edge type,
   1.995 +    /// and the copied map's key type is the from graph's edge
   1.996      /// type.  
   1.997 -    template <typename TargetMap, typename SourceMap>
   1.998 -    BpUGraphCopy& edgeMap(TargetMap& tmap, const SourceMap& map) {
   1.999 -      edgeMapCopies.push_back(new _graph_utils_bits::MapCopy<Source, Edge, 
  1.1000 -                              EdgeRefMap, TargetMap, SourceMap>(tmap, map));
  1.1001 +    template <typename ToMap, typename FromMap>
  1.1002 +    BpUGraphCopy& edgeMap(ToMap& tmap, const FromMap& map) {
  1.1003 +      edgeMapCopies.push_back(new _graph_utils_bits::MapCopy<From, Edge, 
  1.1004 +                              EdgeRefMap, ToMap, FromMap>(tmap, map));
  1.1005        return *this;
  1.1006      }
  1.1007  
  1.1008 @@ -1436,7 +1445,7 @@
  1.1009      ///
  1.1010      /// Make a copy of the given edge.
  1.1011      BpUGraphCopy& edge(TEdge& tedge, const Edge& sedge) {
  1.1012 -      edgeMapCopies.push_back(new _graph_utils_bits::ItemCopy<Source, Edge, 
  1.1013 +      edgeMapCopies.push_back(new _graph_utils_bits::ItemCopy<From, Edge, 
  1.1014                                EdgeRefMap, TEdge>(tedge, sedge));
  1.1015        return *this;
  1.1016      }
  1.1017 @@ -1446,7 +1455,7 @@
  1.1018      /// Copies the undirected edge references into the given map.
  1.1019      template <typename UEdgeRef>
  1.1020      BpUGraphCopy& uEdgeRef(UEdgeRef& map) {
  1.1021 -      uEdgeMapCopies.push_back(new _graph_utils_bits::RefCopy<Source, UEdge, 
  1.1022 +      uEdgeMapCopies.push_back(new _graph_utils_bits::RefCopy<From, UEdge, 
  1.1023                                 UEdgeRefMap, UEdgeRef>(map));
  1.1024        return *this;
  1.1025      }
  1.1026 @@ -1457,7 +1466,7 @@
  1.1027      /// references) into the given map.
  1.1028      template <typename UEdgeCrossRef>
  1.1029      BpUGraphCopy& uEdgeCrossRef(UEdgeCrossRef& map) {
  1.1030 -      uEdgeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<Source, 
  1.1031 +      uEdgeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<From, 
  1.1032                                 UEdge, UEdgeRefMap, UEdgeCrossRef>(map));
  1.1033        return *this;
  1.1034      }
  1.1035 @@ -1465,13 +1474,13 @@
  1.1036      /// \brief Make copy of the given map.
  1.1037      ///
  1.1038      /// Makes copy of the given map for the newly created graph. 
  1.1039 -    /// The new map's key type is the target graph's undirected edge type,
  1.1040 -    /// and the copied map's key type is the source graph's undirected edge
  1.1041 +    /// The new map's key type is the to graph's undirected edge type,
  1.1042 +    /// and the copied map's key type is the from graph's undirected edge
  1.1043      /// type.  
  1.1044 -    template <typename TargetMap, typename SourceMap>
  1.1045 -    BpUGraphCopy& uEdgeMap(TargetMap& tmap, const SourceMap& map) {
  1.1046 -      uEdgeMapCopies.push_back(new _graph_utils_bits::MapCopy<Source, UEdge, 
  1.1047 -                               UEdgeRefMap, TargetMap, SourceMap>(tmap, map));
  1.1048 +    template <typename ToMap, typename FromMap>
  1.1049 +    BpUGraphCopy& uEdgeMap(ToMap& tmap, const FromMap& map) {
  1.1050 +      uEdgeMapCopies.push_back(new _graph_utils_bits::MapCopy<From, UEdge, 
  1.1051 +                               UEdgeRefMap, ToMap, FromMap>(tmap, map));
  1.1052        return *this;
  1.1053      }
  1.1054  
  1.1055 @@ -1479,7 +1488,7 @@
  1.1056      ///
  1.1057      /// Make a copy of the given undirected edge.
  1.1058      BpUGraphCopy& uEdge(TUEdge& tuedge, const UEdge& suedge) {
  1.1059 -      uEdgeMapCopies.push_back(new _graph_utils_bits::ItemCopy<Source, UEdge, 
  1.1060 +      uEdgeMapCopies.push_back(new _graph_utils_bits::ItemCopy<From, UEdge, 
  1.1061                                 UEdgeRefMap, TUEdge>(tuedge, suedge));
  1.1062        return *this;
  1.1063      }
  1.1064 @@ -1488,48 +1497,48 @@
  1.1065      ///
  1.1066      /// Executes the copies.
  1.1067      void run() {
  1.1068 -      ANodeRefMap aNodeRefMap(source);
  1.1069 -      BNodeRefMap bNodeRefMap(source);
  1.1070 -      NodeRefMap nodeRefMap(source, aNodeRefMap, bNodeRefMap);
  1.1071 -      UEdgeRefMap uEdgeRefMap(source);
  1.1072 -      EdgeRefMap edgeRefMap(target, source, uEdgeRefMap, nodeRefMap);
  1.1073 -      _graph_utils_bits::BpUGraphCopySelector<Target>::
  1.1074 -        copy(target, source, aNodeRefMap, bNodeRefMap, uEdgeRefMap);
  1.1075 +      ANodeRefMap aNodeRefMap(from);
  1.1076 +      BNodeRefMap bNodeRefMap(from);
  1.1077 +      NodeRefMap nodeRefMap(from, aNodeRefMap, bNodeRefMap);
  1.1078 +      UEdgeRefMap uEdgeRefMap(from);
  1.1079 +      EdgeRefMap edgeRefMap(to, from, uEdgeRefMap, nodeRefMap);
  1.1080 +      _graph_utils_bits::BpUGraphCopySelector<To>::
  1.1081 +        copy(to, from, aNodeRefMap, bNodeRefMap, uEdgeRefMap);
  1.1082        for (int i = 0; i < int(aNodeMapCopies.size()); ++i) {
  1.1083 -        aNodeMapCopies[i]->copy(source, aNodeRefMap);
  1.1084 +        aNodeMapCopies[i]->copy(from, aNodeRefMap);
  1.1085        }
  1.1086        for (int i = 0; i < int(bNodeMapCopies.size()); ++i) {
  1.1087 -        bNodeMapCopies[i]->copy(source, bNodeRefMap);
  1.1088 +        bNodeMapCopies[i]->copy(from, bNodeRefMap);
  1.1089        }
  1.1090        for (int i = 0; i < int(nodeMapCopies.size()); ++i) {
  1.1091 -        nodeMapCopies[i]->copy(source, nodeRefMap);
  1.1092 +        nodeMapCopies[i]->copy(from, nodeRefMap);
  1.1093        }
  1.1094        for (int i = 0; i < int(uEdgeMapCopies.size()); ++i) {
  1.1095 -        uEdgeMapCopies[i]->copy(source, uEdgeRefMap);
  1.1096 +        uEdgeMapCopies[i]->copy(from, uEdgeRefMap);
  1.1097        }
  1.1098        for (int i = 0; i < int(edgeMapCopies.size()); ++i) {
  1.1099 -        edgeMapCopies[i]->copy(source, edgeRefMap);
  1.1100 +        edgeMapCopies[i]->copy(from, edgeRefMap);
  1.1101        }
  1.1102      }
  1.1103  
  1.1104    private:
  1.1105      
  1.1106 -    const Source& source;
  1.1107 -    Target& target;
  1.1108 +    const From& from;
  1.1109 +    To& to;
  1.1110  
  1.1111 -    std::vector<_graph_utils_bits::MapCopyBase<Source, ANode, ANodeRefMap>* > 
  1.1112 +    std::vector<_graph_utils_bits::MapCopyBase<From, ANode, ANodeRefMap>* > 
  1.1113      aNodeMapCopies;
  1.1114  
  1.1115 -    std::vector<_graph_utils_bits::MapCopyBase<Source, BNode, BNodeRefMap>* > 
  1.1116 +    std::vector<_graph_utils_bits::MapCopyBase<From, BNode, BNodeRefMap>* > 
  1.1117      bNodeMapCopies;
  1.1118  
  1.1119 -    std::vector<_graph_utils_bits::MapCopyBase<Source, Node, NodeRefMap>* > 
  1.1120 +    std::vector<_graph_utils_bits::MapCopyBase<From, Node, NodeRefMap>* > 
  1.1121      nodeMapCopies;
  1.1122  
  1.1123 -    std::vector<_graph_utils_bits::MapCopyBase<Source, Edge, EdgeRefMap>* > 
  1.1124 +    std::vector<_graph_utils_bits::MapCopyBase<From, Edge, EdgeRefMap>* > 
  1.1125      edgeMapCopies;
  1.1126  
  1.1127 -    std::vector<_graph_utils_bits::MapCopyBase<Source, UEdge, UEdgeRefMap>* > 
  1.1128 +    std::vector<_graph_utils_bits::MapCopyBase<From, UEdge, UEdgeRefMap>* > 
  1.1129      uEdgeMapCopies;
  1.1130  
  1.1131    };
  1.1132 @@ -1544,15 +1553,15 @@
  1.1133    ///\endcode
  1.1134    /// 
  1.1135    /// After the copy the \c nr map will contain the mapping from the
  1.1136 -  /// source graph's nodes to the target graph's nodes and the \c ecr will
  1.1137 -  /// contain the mapping from the target graph's edges to the source's
  1.1138 +  /// from graph's nodes to the to graph's nodes and the \c ecr will
  1.1139 +  /// contain the mapping from the to graph's edges to the from's
  1.1140    /// edges.
  1.1141    ///
  1.1142    /// \see BpUGraphCopy
  1.1143 -  template <typename Target, typename Source>
  1.1144 -  BpUGraphCopy<Target, Source> 
  1.1145 -  copyBpUGraph(Target& target, const Source& source) {
  1.1146 -    return BpUGraphCopy<Target, Source>(target, source);
  1.1147 +  template <typename To, typename From>
  1.1148 +  BpUGraphCopy<To, From> 
  1.1149 +  copyBpUGraph(To& to, const From& from) {
  1.1150 +    return BpUGraphCopy<To, From>(to, from);
  1.1151    }
  1.1152  
  1.1153