Changeset 2485:88aa7870756a in lemon0.x for lemon
 Timestamp:
 10/02/07 14:34:43 (12 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@3324
 Location:
 lemon
 Files:

 5 edited
Legend:
 Unmodified
 Added
 Removed

lemon/concepts/bpugraph.h
r2474 r2485 34 34 namespace concepts { 35 35 36 /// \addtogroup graph_concepts 37 /// @{ 36 /// \ingroup graph_concepts 38 37 /// 39 38 /// \brief Class describing the concept of Bipartite Undirected Graphs. … … 999 998 }; 1000 999 1001 1002 /// @}1003 1004 1000 } 1005 1001 
lemon/concepts/graph.h
r2474 r2485 33 33 namespace concepts { 34 34 35 /// \addtogroup graph_concepts 36 /// @{ 35 /// \ingroup graph_concepts 37 36 /// 38 37 /// \brief Class describing the concept of Directed Graphs. … … 447 446 }; 448 447 449 // @}450 448 } //namespace concepts 451 449 } //namespace lemon 
lemon/concepts/graph_components.h
r2474 r2485 1483 1483 template <typename _Value> 1484 1484 class NodeMap : public GraphMap<Graph, Node, _Value> { 1485 private:1486 NodeMap();1487 1485 public: 1488 1486 typedef GraphMap<MappableGraphComponent, Node, _Value> Parent; … … 1491 1489 /// 1492 1490 /// Construct a new map for the graph. 1493 /// \todo call the right parent class constructor1494 1491 explicit NodeMap(const MappableGraphComponent& graph) 1495 1492 : Parent(graph) {} … … 1523 1520 template <typename _Value> 1524 1521 class EdgeMap : public GraphMap<Graph, Edge, _Value> { 1525 private:1526 EdgeMap();1527 1522 public: 1528 1523 typedef GraphMap<MappableGraphComponent, Edge, _Value> Parent; … … 1531 1526 /// 1532 1527 /// Construct a new map for the graph. 1533 /// \todo call the right parent class constructor1534 1528 explicit EdgeMap(const MappableGraphComponent& graph) 1535 1529 : Parent(graph) {} … … 1628 1622 /// 1629 1623 /// Construct a new map for the graph. 1630 /// \todo call the right parent class constructor1631 1624 explicit UEdgeMap(const MappableUGraphComponent& graph) 1632 1625 : Parent(graph) {} … … 1713 1706 /// 1714 1707 /// Construct a new map for the graph. 1715 /// \todo call the right parent class constructor1716 1708 explicit ANodeMap(const MappableBpUGraphComponent& graph) 1717 1709 : Parent(graph) {} … … 1751 1743 /// 1752 1744 /// Construct a new map for the graph. 1753 /// \todo call the right parent class constructor1754 1745 explicit BNodeMap(const MappableBpUGraphComponent& graph) 1755 1746 : Parent(graph) {} 
lemon/concepts/ugraph.h
r2474 r2485 31 31 namespace concepts { 32 32 33 /// \addtogroup graph_concepts 34 /// @{ 33 /// \ingroup graph_concepts 35 34 /// 36 35 /// \brief Class describing the concept of Undirected Graphs. … … 697 696 }; 698 697 699 /// @}700 701 698 } 702 699 
lemon/graph_utils.h
r2476 r2485 147 147 /// graph structures it is specialized to run in O(1). 148 148 /// 149 /// \todo Refer how to specialize it. 150 149 /// If the graph contains a \e nodeNum() member function and a 150 /// \e NodeNumTag tag then this function calls directly the member 151 /// function to query the cardinality of the node set. 151 152 template <typename Graph> 152 153 inline int countNodes(const Graph& g) { … … 180 181 /// graph structures it is specialized to run in O(1). 181 182 /// 182 /// \todo Refer how to specialize it. 183 183 /// If the graph contains an \e aNodeNum() member function and a 184 /// \e NodeNumTag tag then this function calls directly the member 185 /// function to query the cardinality of the Anode set. 184 186 template <typename Graph> 185 187 inline int countANodes(const Graph& g) { … … 213 215 /// graph structures it is specialized to run in O(1). 214 216 /// 215 /// \todo Refer how to specialize it. 216 217 /// If the graph contains a \e bNodeNum() member function and a 218 /// \e NodeNumTag tag then this function calls directly the member 219 /// function to query the cardinality of the Bnode set. 217 220 template <typename Graph> 218 221 inline int countBNodes(const Graph& g) { … … 248 251 /// The complexity of the function is O(e) but for some 249 252 /// graph structures it is specialized to run in O(1). 250 253 /// 254 /// If the graph contains a \e edgeNum() member function and a 255 /// \e EdgeNumTag tag then this function calls directly the member 256 /// function to query the cardinality of the edge set. 251 257 template <typename Graph> 252 258 inline int countEdges(const Graph& g) { … … 280 286 /// The complexity of the function is O(e) but for some 281 287 /// graph structures it is specialized to run in O(1). 282 288 /// 289 /// If the graph contains a \e uEdgeNum() member function and a 290 /// \e EdgeNumTag tag then this function calls directly the member 291 /// function to query the cardinality of the undirected edge set. 283 292 template <typename Graph> 284 293 inline int countUEdges(const Graph& g) { … … 560 569 /// \brief Copy a map. 561 570 /// 562 /// This function copies the \c source map to the \c targetmap. It uses the571 /// This function copies the \c from map to the \c to map. It uses the 563 572 /// given iterator to iterate on the data structure and it uses the \c ref 564 /// mapping to convert the source's keys to the target's keys.565 template <typename T arget, typename Source,573 /// mapping to convert the from's keys to the to's keys. 574 template <typename To, typename From, 566 575 typename ItemIt, typename Ref> 567 void copyMap(T arget& target, const Source& source,576 void copyMap(To& to, const From& from, 568 577 ItemIt it, const Ref& ref) { 569 578 for (; it != INVALID; ++it) { 570 t arget[ref[it]] = source[it];571 } 572 } 573 574 /// \brief Copy the source map to the targetmap.575 /// 576 /// Copy the \c source map to the \c targetmap. It uses the given iterator579 to[ref[it]] = from[it]; 580 } 581 } 582 583 /// \brief Copy the from map to the to map. 584 /// 585 /// Copy the \c from map to the \c to map. It uses the given iterator 577 586 /// to iterate on the data structure. 578 template <typename T arget, typename Source, typename ItemIt>579 void copyMap(T arget& target, const Source& source, ItemIt it) {587 template <typename To, typename From, typename ItemIt> 588 void copyMap(To& to, const From& from, ItemIt it) { 580 589 for (; it != INVALID; ++it) { 581 t arget[it] = source[it];590 to[it] = from[it]; 582 591 } 583 592 } … … 588 597 class MapCopyBase { 589 598 public: 590 virtual void copy(const Graph& source, const RefMap& refMap) = 0;599 virtual void copy(const Graph& from, const RefMap& refMap) = 0; 591 600 592 601 virtual ~MapCopyBase() {} … … 594 603 595 604 template <typename Graph, typename Item, typename RefMap, 596 typename T argetMap, typename SourceMap>605 typename ToMap, typename FromMap> 597 606 class MapCopy : public MapCopyBase<Graph, Item, RefMap> { 598 607 public: 599 608 600 MapCopy(T argetMap& tmap, const SourceMap& map)609 MapCopy(ToMap& tmap, const FromMap& map) 601 610 : _tmap(tmap), _map(map) {} 602 611 … … 609 618 610 619 private: 611 T argetMap& _tmap;612 const SourceMap& _map;620 ToMap& _tmap; 621 const FromMap& _map; 613 622 }; 614 623 … … 665 674 template <typename Graph, typename Enable = void> 666 675 struct GraphCopySelector { 667 template <typename Source, typename NodeRefMap, typename EdgeRefMap>668 static void copy(Graph &t arget, const Source& source,676 template <typename From, typename NodeRefMap, typename EdgeRefMap> 677 static void copy(Graph &to, const From& from, 669 678 NodeRefMap& nodeRefMap, EdgeRefMap& edgeRefMap) { 670 for (typename Source::NodeIt it(source); it != INVALID; ++it) {671 nodeRefMap[it] = t arget.addNode();679 for (typename From::NodeIt it(from); it != INVALID; ++it) { 680 nodeRefMap[it] = to.addNode(); 672 681 } 673 for (typename Source::EdgeIt it(source); it != INVALID; ++it) {674 edgeRefMap[it] = t arget.addEdge(nodeRefMap[source.source(it)],675 nodeRefMap[ source.target(it)]);682 for (typename From::EdgeIt it(from); it != INVALID; ++it) { 683 edgeRefMap[it] = to.addEdge(nodeRefMap[from.source(it)], 684 nodeRefMap[from.target(it)]); 676 685 } 677 686 } … … 683 692 typename enable_if<typename Graph::BuildTag, void>::type> 684 693 { 685 template <typename Source, typename NodeRefMap, typename EdgeRefMap>686 static void copy(Graph &t arget, const Source& source,694 template <typename From, typename NodeRefMap, typename EdgeRefMap> 695 static void copy(Graph &to, const From& from, 687 696 NodeRefMap& nodeRefMap, EdgeRefMap& edgeRefMap) { 688 t arget.build(source, nodeRefMap, edgeRefMap);697 to.build(from, nodeRefMap, edgeRefMap); 689 698 } 690 699 }; … … 692 701 template <typename UGraph, typename Enable = void> 693 702 struct UGraphCopySelector { 694 template <typename Source, typename NodeRefMap, typename UEdgeRefMap>695 static void copy(UGraph &t arget, const Source& source,703 template <typename From, typename NodeRefMap, typename UEdgeRefMap> 704 static void copy(UGraph &to, const From& from, 696 705 NodeRefMap& nodeRefMap, UEdgeRefMap& uEdgeRefMap) { 697 for (typename Source::NodeIt it(source); it != INVALID; ++it) {698 nodeRefMap[it] = t arget.addNode();706 for (typename From::NodeIt it(from); it != INVALID; ++it) { 707 nodeRefMap[it] = to.addNode(); 699 708 } 700 for (typename Source::UEdgeIt it(source); it != INVALID; ++it) {701 uEdgeRefMap[it] = t arget.addEdge(nodeRefMap[source.source(it)],702 nodeRefMap[source.target(it)]);709 for (typename From::UEdgeIt it(from); it != INVALID; ++it) { 710 uEdgeRefMap[it] = to.addEdge(nodeRefMap[from.source(it)], 711 nodeRefMap[from.target(it)]); 703 712 } 704 713 } … … 710 719 typename enable_if<typename UGraph::BuildTag, void>::type> 711 720 { 712 template <typename Source, typename NodeRefMap, typename UEdgeRefMap>713 static void copy(UGraph &t arget, const Source& source,721 template <typename From, typename NodeRefMap, typename UEdgeRefMap> 722 static void copy(UGraph &to, const From& from, 714 723 NodeRefMap& nodeRefMap, UEdgeRefMap& uEdgeRefMap) { 715 t arget.build(source, nodeRefMap, uEdgeRefMap);724 to.build(from, nodeRefMap, uEdgeRefMap); 716 725 } 717 726 }; … … 719 728 template <typename BpUGraph, typename Enable = void> 720 729 struct BpUGraphCopySelector { 721 template <typename Source, typename ANodeRefMap,730 template <typename From, typename ANodeRefMap, 722 731 typename BNodeRefMap, typename UEdgeRefMap> 723 static void copy(BpUGraph &t arget, const Source& source,732 static void copy(BpUGraph &to, const From& from, 724 733 ANodeRefMap& aNodeRefMap, BNodeRefMap& bNodeRefMap, 725 734 UEdgeRefMap& uEdgeRefMap) { 726 for (typename Source::ANodeIt it(source); it != INVALID; ++it) {727 aNodeRefMap[it] = t arget.addANode();735 for (typename From::ANodeIt it(from); it != INVALID; ++it) { 736 aNodeRefMap[it] = to.addANode(); 728 737 } 729 for (typename Source::BNodeIt it(source); it != INVALID; ++it) {730 bNodeRefMap[it] = t arget.addBNode();738 for (typename From::BNodeIt it(from); it != INVALID; ++it) { 739 bNodeRefMap[it] = to.addBNode(); 731 740 } 732 for (typename Source::UEdgeIt it(source); it != INVALID; ++it) {733 uEdgeRefMap[it] = t arget.addEdge(aNodeRefMap[source.aNode(it)],734 bNodeRefMap[ source.bNode(it)]);741 for (typename From::UEdgeIt it(from); it != INVALID; ++it) { 742 uEdgeRefMap[it] = to.addEdge(aNodeRefMap[from.aNode(it)], 743 bNodeRefMap[from.bNode(it)]); 735 744 } 736 745 } … … 742 751 typename enable_if<typename BpUGraph::BuildTag, void>::type> 743 752 { 744 template <typename Source, typename ANodeRefMap,753 template <typename From, typename ANodeRefMap, 745 754 typename BNodeRefMap, typename UEdgeRefMap> 746 static void copy(BpUGraph &t arget, const Source& source,755 static void copy(BpUGraph &to, const From& from, 747 756 ANodeRefMap& aNodeRefMap, BNodeRefMap& bNodeRefMap, 748 757 UEdgeRefMap& uEdgeRefMap) { 749 t arget.build(source, aNodeRefMap, bNodeRefMap, uEdgeRefMap);758 to.build(from, aNodeRefMap, bNodeRefMap, uEdgeRefMap); 750 759 } 751 760 }; … … 758 767 /// Class to copy a graph to another graph (duplicate a graph). The 759 768 /// simplest way of using it is through the \c copyGraph() function. 760 template <typename T arget, typename Source>769 template <typename To, typename From> 761 770 class GraphCopy { 762 771 private: 763 772 764 typedef typename Source::Node Node;765 typedef typename Source::NodeIt NodeIt;766 typedef typename Source::Edge Edge;767 typedef typename Source::EdgeIt EdgeIt;768 769 typedef typename T arget::Node TNode;770 typedef typename T arget::Edge TEdge;771 772 typedef typename Source::template NodeMap<TNode> NodeRefMap;773 typedef typename Source::template EdgeMap<TEdge> EdgeRefMap;773 typedef typename From::Node Node; 774 typedef typename From::NodeIt NodeIt; 775 typedef typename From::Edge Edge; 776 typedef typename From::EdgeIt EdgeIt; 777 778 typedef typename To::Node TNode; 779 typedef typename To::Edge TEdge; 780 781 typedef typename From::template NodeMap<TNode> NodeRefMap; 782 typedef typename From::template EdgeMap<TEdge> EdgeRefMap; 774 783 775 784 … … 779 788 /// \brief Constructor for the GraphCopy. 780 789 /// 781 /// It copies the content of the \c _ sourcegraph into the782 /// \c _t argetgraph.783 GraphCopy(T arget& _target, const Source& _source)784 : source(_source), target(_target) {}790 /// It copies the content of the \c _from graph into the 791 /// \c _to graph. 792 GraphCopy(To& _to, const From& _from) 793 : from(_from), to(_to) {} 785 794 786 795 /// \brief Destructor of the GraphCopy … … 802 811 template <typename NodeRef> 803 812 GraphCopy& nodeRef(NodeRef& map) { 804 nodeMapCopies.push_back(new _graph_utils_bits::RefCopy< Source, Node,813 nodeMapCopies.push_back(new _graph_utils_bits::RefCopy<From, Node, 805 814 NodeRefMap, NodeRef>(map)); 806 815 return *this; … … 813 822 template <typename NodeCrossRef> 814 823 GraphCopy& nodeCrossRef(NodeCrossRef& map) { 815 nodeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy< Source, Node,824 nodeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<From, Node, 816 825 NodeRefMap, NodeCrossRef>(map)); 817 826 return *this; … … 821 830 /// 822 831 /// Makes copy of the given map for the newly created graph. 823 /// The new map's key type is the t argetgraph's node type,824 /// and the copied map's key type is the sourcegraph's node832 /// The new map's key type is the to graph's node type, 833 /// and the copied map's key type is the from graph's node 825 834 /// type. 826 template <typename T argetMap, typename SourceMap>827 GraphCopy& nodeMap(T argetMap& tmap, const SourceMap& map) {828 nodeMapCopies.push_back(new _graph_utils_bits::MapCopy< Source, Node,829 NodeRefMap, T argetMap, SourceMap>(tmap, map));835 template <typename ToMap, typename FromMap> 836 GraphCopy& nodeMap(ToMap& tmap, const FromMap& map) { 837 nodeMapCopies.push_back(new _graph_utils_bits::MapCopy<From, Node, 838 NodeRefMap, ToMap, FromMap>(tmap, map)); 830 839 return *this; 831 840 } … … 835 844 /// Make a copy of the given node. 836 845 GraphCopy& node(TNode& tnode, const Node& snode) { 837 nodeMapCopies.push_back(new _graph_utils_bits::ItemCopy< Source, Node,846 nodeMapCopies.push_back(new _graph_utils_bits::ItemCopy<From, Node, 838 847 NodeRefMap, TNode>(tnode, snode)); 839 848 return *this; … … 845 854 template <typename EdgeRef> 846 855 GraphCopy& edgeRef(EdgeRef& map) { 847 edgeMapCopies.push_back(new _graph_utils_bits::RefCopy< Source, Edge,856 edgeMapCopies.push_back(new _graph_utils_bits::RefCopy<From, Edge, 848 857 EdgeRefMap, EdgeRef>(map)); 849 858 return *this; … … 856 865 template <typename EdgeCrossRef> 857 866 GraphCopy& edgeCrossRef(EdgeCrossRef& map) { 858 edgeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy< Source, Edge,867 edgeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<From, Edge, 859 868 EdgeRefMap, EdgeCrossRef>(map)); 860 869 return *this; … … 864 873 /// 865 874 /// Makes copy of the given map for the newly created graph. 866 /// The new map's key type is the t argetgraph's edge type,867 /// and the copied map's key type is the sourcegraph's edge875 /// The new map's key type is the to graph's edge type, 876 /// and the copied map's key type is the from graph's edge 868 877 /// type. 869 template <typename T argetMap, typename SourceMap>870 GraphCopy& edgeMap(T argetMap& tmap, const SourceMap& map) {871 edgeMapCopies.push_back(new _graph_utils_bits::MapCopy< Source, Edge,872 EdgeRefMap, T argetMap, SourceMap>(tmap, map));878 template <typename ToMap, typename FromMap> 879 GraphCopy& edgeMap(ToMap& tmap, const FromMap& map) { 880 edgeMapCopies.push_back(new _graph_utils_bits::MapCopy<From, Edge, 881 EdgeRefMap, ToMap, FromMap>(tmap, map)); 873 882 return *this; 874 883 } … … 878 887 /// Make a copy of the given edge. 879 888 GraphCopy& edge(TEdge& tedge, const Edge& sedge) { 880 edgeMapCopies.push_back(new _graph_utils_bits::ItemCopy< Source, Edge,889 edgeMapCopies.push_back(new _graph_utils_bits::ItemCopy<From, Edge, 881 890 EdgeRefMap, TEdge>(tedge, sedge)); 882 891 return *this; … … 887 896 /// Executes the copies. 888 897 void run() { 889 NodeRefMap nodeRefMap( source);890 EdgeRefMap edgeRefMap( source);891 _graph_utils_bits::GraphCopySelector<T arget>::892 copy(t arget, source, nodeRefMap, edgeRefMap);898 NodeRefMap nodeRefMap(from); 899 EdgeRefMap edgeRefMap(from); 900 _graph_utils_bits::GraphCopySelector<To>:: 901 copy(to, from, nodeRefMap, edgeRefMap); 893 902 for (int i = 0; i < int(nodeMapCopies.size()); ++i) { 894 nodeMapCopies[i]>copy( source, nodeRefMap);903 nodeMapCopies[i]>copy(from, nodeRefMap); 895 904 } 896 905 for (int i = 0; i < int(edgeMapCopies.size()); ++i) { 897 edgeMapCopies[i]>copy( source, edgeRefMap);906 edgeMapCopies[i]>copy(from, edgeRefMap); 898 907 } 899 908 } … … 902 911 903 912 904 const Source& source;905 T arget& target;906 907 std::vector<_graph_utils_bits::MapCopyBase< Source, Node, NodeRefMap>* >913 const From& from; 914 To& to; 915 916 std::vector<_graph_utils_bits::MapCopyBase<From, Node, NodeRefMap>* > 908 917 nodeMapCopies; 909 918 910 std::vector<_graph_utils_bits::MapCopyBase< Source, Edge, EdgeRefMap>* >919 std::vector<_graph_utils_bits::MapCopyBase<From, Edge, EdgeRefMap>* > 911 920 edgeMapCopies; 912 921 … … 923 932 /// 924 933 /// After the copy the \c nr map will contain the mapping from the 925 /// source graph's nodes to the targetgraph's nodes and the \c ecr will926 /// contain the mapping from the t arget graph's edges to the source's934 /// from graph's nodes to the to graph's nodes and the \c ecr will 935 /// contain the mapping from the to graph's edges to the from's 927 936 /// edges. 928 937 /// 929 938 /// \see GraphCopy 930 template <typename T arget, typename Source>931 GraphCopy<T arget, Source> copyGraph(Target& target, const Source& source) {932 return GraphCopy<T arget, Source>(target, source);939 template <typename To, typename From> 940 GraphCopy<To, From> copyGraph(To& to, const From& from) { 941 return GraphCopy<To, From>(to, from); 933 942 } 934 943 … … 937 946 /// Class to copy an undirected graph to another graph (duplicate a graph). 938 947 /// The simplest way of using it is through the \c copyUGraph() function. 939 template <typename T arget, typename Source>948 template <typename To, typename From> 940 949 class UGraphCopy { 941 950 private: 942 951 943 typedef typename Source::Node Node;944 typedef typename Source::NodeIt NodeIt;945 typedef typename Source::Edge Edge;946 typedef typename Source::EdgeIt EdgeIt;947 typedef typename Source::UEdge UEdge;948 typedef typename Source::UEdgeIt UEdgeIt;949 950 typedef typename T arget::Node TNode;951 typedef typename T arget::Edge TEdge;952 typedef typename T arget::UEdge TUEdge;953 954 typedef typename Source::template NodeMap<TNode> NodeRefMap;955 typedef typename Source::template UEdgeMap<TUEdge> UEdgeRefMap;952 typedef typename From::Node Node; 953 typedef typename From::NodeIt NodeIt; 954 typedef typename From::Edge Edge; 955 typedef typename From::EdgeIt EdgeIt; 956 typedef typename From::UEdge UEdge; 957 typedef typename From::UEdgeIt UEdgeIt; 958 959 typedef typename To::Node TNode; 960 typedef typename To::Edge TEdge; 961 typedef typename To::UEdge TUEdge; 962 963 typedef typename From::template NodeMap<TNode> NodeRefMap; 964 typedef typename From::template UEdgeMap<TUEdge> UEdgeRefMap; 956 965 957 966 struct EdgeRefMap { 958 EdgeRefMap(const T arget& _target, const Source& _source,967 EdgeRefMap(const To& _to, const From& _from, 959 968 const UEdgeRefMap& _uedge_ref, const NodeRefMap& _node_ref) 960 : t arget(_target), source(_source),969 : to(_to), from(_from), 961 970 uedge_ref(_uedge_ref), node_ref(_node_ref) {} 962 971 963 typedef typename Source::Edge Key;964 typedef typename T arget::Edge Value;972 typedef typename From::Edge Key; 973 typedef typename To::Edge Value; 965 974 966 975 Value operator[](const Key& key) const { 967 976 bool forward = 968 ( source.direction(key) ==969 (node_ref[ source.source(static_cast<const UEdge&>(key))] ==970 t arget.source(uedge_ref[static_cast<const UEdge&>(key)])));971 return t arget.direct(uedge_ref[key], forward);977 (from.direction(key) == 978 (node_ref[from.source(static_cast<const UEdge&>(key))] == 979 to.source(uedge_ref[static_cast<const UEdge&>(key)]))); 980 return to.direct(uedge_ref[key], forward); 972 981 } 973 982 974 const T arget& target;975 const Source& source;983 const To& to; 984 const From& from; 976 985 const UEdgeRefMap& uedge_ref; 977 986 const NodeRefMap& node_ref; … … 984 993 /// \brief Constructor for the GraphCopy. 985 994 /// 986 /// It copies the content of the \c _ sourcegraph into the987 /// \c _t argetgraph.988 UGraphCopy(T arget& _target, const Source& _source)989 : source(_source), target(_target) {}995 /// It copies the content of the \c _from graph into the 996 /// \c _to graph. 997 UGraphCopy(To& _to, const From& _from) 998 : from(_from), to(_to) {} 990 999 991 1000 /// \brief Destructor of the GraphCopy … … 1010 1019 template <typename NodeRef> 1011 1020 UGraphCopy& nodeRef(NodeRef& map) { 1012 nodeMapCopies.push_back(new _graph_utils_bits::RefCopy< Source, Node,1021 nodeMapCopies.push_back(new _graph_utils_bits::RefCopy<From, Node, 1013 1022 NodeRefMap, NodeRef>(map)); 1014 1023 return *this; … … 1021 1030 template <typename NodeCrossRef> 1022 1031 UGraphCopy& nodeCrossRef(NodeCrossRef& map) { 1023 nodeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy< Source, Node,1032 nodeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<From, Node, 1024 1033 NodeRefMap, NodeCrossRef>(map)); 1025 1034 return *this; … … 1029 1038 /// 1030 1039 /// Makes copy of the given map for the newly created graph. 1031 /// The new map's key type is the t argetgraph's node type,1032 /// and the copied map's key type is the sourcegraph's node1040 /// The new map's key type is the to graph's node type, 1041 /// and the copied map's key type is the from graph's node 1033 1042 /// type. 1034 template <typename T argetMap, typename SourceMap>1035 UGraphCopy& nodeMap(T argetMap& tmap, const SourceMap& map) {1036 nodeMapCopies.push_back(new _graph_utils_bits::MapCopy< Source, Node,1037 NodeRefMap, T argetMap, SourceMap>(tmap, map));1043 template <typename ToMap, typename FromMap> 1044 UGraphCopy& nodeMap(ToMap& tmap, const FromMap& map) { 1045 nodeMapCopies.push_back(new _graph_utils_bits::MapCopy<From, Node, 1046 NodeRefMap, ToMap, FromMap>(tmap, map)); 1038 1047 return *this; 1039 1048 } … … 1043 1052 /// Make a copy of the given node. 1044 1053 UGraphCopy& node(TNode& tnode, const Node& snode) { 1045 nodeMapCopies.push_back(new _graph_utils_bits::ItemCopy< Source, Node,1054 nodeMapCopies.push_back(new _graph_utils_bits::ItemCopy<From, Node, 1046 1055 NodeRefMap, TNode>(tnode, snode)); 1047 1056 return *this; … … 1053 1062 template <typename EdgeRef> 1054 1063 UGraphCopy& edgeRef(EdgeRef& map) { 1055 edgeMapCopies.push_back(new _graph_utils_bits::RefCopy< Source, Edge,1064 edgeMapCopies.push_back(new _graph_utils_bits::RefCopy<From, Edge, 1056 1065 EdgeRefMap, EdgeRef>(map)); 1057 1066 return *this; … … 1064 1073 template <typename EdgeCrossRef> 1065 1074 UGraphCopy& edgeCrossRef(EdgeCrossRef& map) { 1066 edgeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy< Source, Edge,1075 edgeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<From, Edge, 1067 1076 EdgeRefMap, EdgeCrossRef>(map)); 1068 1077 return *this; … … 1072 1081 /// 1073 1082 /// Makes copy of the given map for the newly created graph. 1074 /// The new map's key type is the t argetgraph's edge type,1075 /// and the copied map's key type is the sourcegraph's edge1083 /// The new map's key type is the to graph's edge type, 1084 /// and the copied map's key type is the from graph's edge 1076 1085 /// type. 1077 template <typename T argetMap, typename SourceMap>1078 UGraphCopy& edgeMap(T argetMap& tmap, const SourceMap& map) {1079 edgeMapCopies.push_back(new _graph_utils_bits::MapCopy< Source, Edge,1080 EdgeRefMap, T argetMap, SourceMap>(tmap, map));1086 template <typename ToMap, typename FromMap> 1087 UGraphCopy& edgeMap(ToMap& tmap, const FromMap& map) { 1088 edgeMapCopies.push_back(new _graph_utils_bits::MapCopy<From, Edge, 1089 EdgeRefMap, ToMap, FromMap>(tmap, map)); 1081 1090 return *this; 1082 1091 } … … 1086 1095 /// Make a copy of the given edge. 1087 1096 UGraphCopy& edge(TEdge& tedge, const Edge& sedge) { 1088 edgeMapCopies.push_back(new _graph_utils_bits::ItemCopy< Source, Edge,1097 edgeMapCopies.push_back(new _graph_utils_bits::ItemCopy<From, Edge, 1089 1098 EdgeRefMap, TEdge>(tedge, sedge)); 1090 1099 return *this; … … 1096 1105 template <typename UEdgeRef> 1097 1106 UGraphCopy& uEdgeRef(UEdgeRef& map) { 1098 uEdgeMapCopies.push_back(new _graph_utils_bits::RefCopy< Source, UEdge,1107 uEdgeMapCopies.push_back(new _graph_utils_bits::RefCopy<From, UEdge, 1099 1108 UEdgeRefMap, UEdgeRef>(map)); 1100 1109 return *this; … … 1107 1116 template <typename UEdgeCrossRef> 1108 1117 UGraphCopy& uEdgeCrossRef(UEdgeCrossRef& map) { 1109 uEdgeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy< Source,1118 uEdgeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<From, 1110 1119 UEdge, UEdgeRefMap, UEdgeCrossRef>(map)); 1111 1120 return *this; … … 1115 1124 /// 1116 1125 /// Makes copy of the given map for the newly created graph. 1117 /// The new map's key type is the t argetgraph's undirected edge type,1118 /// and the copied map's key type is the sourcegraph's undirected edge1126 /// The new map's key type is the to graph's undirected edge type, 1127 /// and the copied map's key type is the from graph's undirected edge 1119 1128 /// type. 1120 template <typename T argetMap, typename SourceMap>1121 UGraphCopy& uEdgeMap(T argetMap& tmap, const SourceMap& map) {1122 uEdgeMapCopies.push_back(new _graph_utils_bits::MapCopy< Source, UEdge,1123 UEdgeRefMap, T argetMap, SourceMap>(tmap, map));1129 template <typename ToMap, typename FromMap> 1130 UGraphCopy& uEdgeMap(ToMap& tmap, const FromMap& map) { 1131 uEdgeMapCopies.push_back(new _graph_utils_bits::MapCopy<From, UEdge, 1132 UEdgeRefMap, ToMap, FromMap>(tmap, map)); 1124 1133 return *this; 1125 1134 } … … 1129 1138 /// Make a copy of the given undirected edge. 1130 1139 UGraphCopy& uEdge(TUEdge& tuedge, const UEdge& suedge) { 1131 uEdgeMapCopies.push_back(new _graph_utils_bits::ItemCopy< Source, UEdge,1140 uEdgeMapCopies.push_back(new _graph_utils_bits::ItemCopy<From, UEdge, 1132 1141 UEdgeRefMap, TUEdge>(tuedge, suedge)); 1133 1142 return *this; … … 1138 1147 /// Executes the copies. 1139 1148 void run() { 1140 NodeRefMap nodeRefMap( source);1141 UEdgeRefMap uEdgeRefMap( source);1142 EdgeRefMap edgeRefMap(t arget, source, uEdgeRefMap, nodeRefMap);1143 _graph_utils_bits::UGraphCopySelector<T arget>::1144 copy(t arget, source, nodeRefMap, uEdgeRefMap);1149 NodeRefMap nodeRefMap(from); 1150 UEdgeRefMap uEdgeRefMap(from); 1151 EdgeRefMap edgeRefMap(to, from, uEdgeRefMap, nodeRefMap); 1152 _graph_utils_bits::UGraphCopySelector<To>:: 1153 copy(to, from, nodeRefMap, uEdgeRefMap); 1145 1154 for (int i = 0; i < int(nodeMapCopies.size()); ++i) { 1146 nodeMapCopies[i]>copy( source, nodeRefMap);1155 nodeMapCopies[i]>copy(from, nodeRefMap); 1147 1156 } 1148 1157 for (int i = 0; i < int(uEdgeMapCopies.size()); ++i) { 1149 uEdgeMapCopies[i]>copy( source, uEdgeRefMap);1158 uEdgeMapCopies[i]>copy(from, uEdgeRefMap); 1150 1159 } 1151 1160 for (int i = 0; i < int(edgeMapCopies.size()); ++i) { 1152 edgeMapCopies[i]>copy( source, edgeRefMap);1161 edgeMapCopies[i]>copy(from, edgeRefMap); 1153 1162 } 1154 1163 } … … 1156 1165 private: 1157 1166 1158 const Source& source;1159 T arget& target;1160 1161 std::vector<_graph_utils_bits::MapCopyBase< Source, Node, NodeRefMap>* >1167 const From& from; 1168 To& to; 1169 1170 std::vector<_graph_utils_bits::MapCopyBase<From, Node, NodeRefMap>* > 1162 1171 nodeMapCopies; 1163 1172 1164 std::vector<_graph_utils_bits::MapCopyBase< Source, Edge, EdgeRefMap>* >1173 std::vector<_graph_utils_bits::MapCopyBase<From, Edge, EdgeRefMap>* > 1165 1174 edgeMapCopies; 1166 1175 1167 std::vector<_graph_utils_bits::MapCopyBase< Source, UEdge, UEdgeRefMap>* >1176 std::vector<_graph_utils_bits::MapCopyBase<From, UEdge, UEdgeRefMap>* > 1168 1177 uEdgeMapCopies; 1169 1178 … … 1180 1189 /// 1181 1190 /// After the copy the \c nr map will contain the mapping from the 1182 /// source graph's nodes to the targetgraph's nodes and the \c ecr will1183 /// contain the mapping from the t arget graph's edges to the source's1191 /// from graph's nodes to the to graph's nodes and the \c ecr will 1192 /// contain the mapping from the to graph's edges to the from's 1184 1193 /// edges. 1185 1194 /// 1186 1195 /// \see UGraphCopy 1187 template <typename T arget, typename Source>1188 UGraphCopy<T arget, Source>1189 copyUGraph(T arget& target, const Source& source) {1190 return UGraphCopy<T arget, Source>(target, source);1196 template <typename To, typename From> 1197 UGraphCopy<To, From> 1198 copyUGraph(To& to, const From& from) { 1199 return UGraphCopy<To, From>(to, from); 1191 1200 } 1192 1201 … … 1196 1205 /// (duplicate a graph). The simplest way of using it is through 1197 1206 /// the \c copyBpUGraph() function. 1198 template <typename T arget, typename Source>1207 template <typename To, typename From> 1199 1208 class BpUGraphCopy { 1200 1209 private: 1201 1210 1202 typedef typename Source::Node Node;1203 typedef typename Source::ANode ANode;1204 typedef typename Source::BNode BNode;1205 typedef typename Source::NodeIt NodeIt;1206 typedef typename Source::Edge Edge;1207 typedef typename Source::EdgeIt EdgeIt;1208 typedef typename Source::UEdge UEdge;1209 typedef typename Source::UEdgeIt UEdgeIt;1210 1211 typedef typename T arget::Node TNode;1212 typedef typename T arget::Edge TEdge;1213 typedef typename T arget::UEdge TUEdge;1214 1215 typedef typename Source::template ANodeMap<TNode> ANodeRefMap;1216 typedef typename Source::template BNodeMap<TNode> BNodeRefMap;1217 typedef typename Source::template UEdgeMap<TUEdge> UEdgeRefMap;1211 typedef typename From::Node Node; 1212 typedef typename From::ANode ANode; 1213 typedef typename From::BNode BNode; 1214 typedef typename From::NodeIt NodeIt; 1215 typedef typename From::Edge Edge; 1216 typedef typename From::EdgeIt EdgeIt; 1217 typedef typename From::UEdge UEdge; 1218 typedef typename From::UEdgeIt UEdgeIt; 1219 1220 typedef typename To::Node TNode; 1221 typedef typename To::Edge TEdge; 1222 typedef typename To::UEdge TUEdge; 1223 1224 typedef typename From::template ANodeMap<TNode> ANodeRefMap; 1225 typedef typename From::template BNodeMap<TNode> BNodeRefMap; 1226 typedef typename From::template UEdgeMap<TUEdge> UEdgeRefMap; 1218 1227 1219 1228 struct NodeRefMap { 1220 NodeRefMap(const Source& _source, const ANodeRefMap& _anode_ref,1229 NodeRefMap(const From& _from, const ANodeRefMap& _anode_ref, 1221 1230 const BNodeRefMap& _bnode_ref) 1222 : source(_source), anode_ref(_anode_ref), bnode_ref(_bnode_ref) {}1223 1224 typedef typename Source::Node Key;1225 typedef typename T arget::Node Value;1231 : from(_from), anode_ref(_anode_ref), bnode_ref(_bnode_ref) {} 1232 1233 typedef typename From::Node Key; 1234 typedef typename To::Node Value; 1226 1235 1227 1236 Value operator[](const Key& key) const { 1228 return source.aNode(key) ? anode_ref[key] : bnode_ref[key];1237 return from.aNode(key) ? anode_ref[key] : bnode_ref[key]; 1229 1238 } 1230 1239 1231 const Source& source;1240 const From& from; 1232 1241 const ANodeRefMap& anode_ref; 1233 1242 const BNodeRefMap& bnode_ref; … … 1235 1244 1236 1245 struct EdgeRefMap { 1237 EdgeRefMap(const T arget& _target, const Source& _source,1246 EdgeRefMap(const To& _to, const From& _from, 1238 1247 const UEdgeRefMap& _uedge_ref, const NodeRefMap& _node_ref) 1239 : t arget(_target), source(_source),1248 : to(_to), from(_from), 1240 1249 uedge_ref(_uedge_ref), node_ref(_node_ref) {} 1241 1250 1242 typedef typename Source::Edge Key;1243 typedef typename T arget::Edge Value;1251 typedef typename From::Edge Key; 1252 typedef typename To::Edge Value; 1244 1253 1245 1254 Value operator[](const Key& key) const { 1246 1255 bool forward = 1247 ( source.direction(key) ==1248 (node_ref[ source.source(static_cast<const UEdge&>(key))] ==1249 t arget.source(uedge_ref[static_cast<const UEdge&>(key)])));1250 return t arget.direct(uedge_ref[key], forward);1256 (from.direction(key) == 1257 (node_ref[from.source(static_cast<const UEdge&>(key))] == 1258 to.source(uedge_ref[static_cast<const UEdge&>(key)]))); 1259 return to.direct(uedge_ref[key], forward); 1251 1260 } 1252 1261 1253 const T arget& target;1254 const Source& source;1262 const To& to; 1263 const From& from; 1255 1264 const UEdgeRefMap& uedge_ref; 1256 1265 const NodeRefMap& node_ref; … … 1262 1271 /// \brief Constructor for the GraphCopy. 1263 1272 /// 1264 /// It copies the content of the \c _ sourcegraph into the1265 /// \c _t argetgraph.1266 BpUGraphCopy(T arget& _target, const Source& _source)1267 : source(_source), target(_target) {}1273 /// It copies the content of the \c _from graph into the 1274 /// \c _to graph. 1275 BpUGraphCopy(To& _to, const From& _from) 1276 : from(_from), to(_to) {} 1268 1277 1269 1278 /// \brief Destructor of the GraphCopy … … 1294 1303 template <typename ANodeRef> 1295 1304 BpUGraphCopy& aNodeRef(ANodeRef& map) { 1296 aNodeMapCopies.push_back(new _graph_utils_bits::RefCopy< Source, ANode,1305 aNodeMapCopies.push_back(new _graph_utils_bits::RefCopy<From, ANode, 1297 1306 ANodeRefMap, ANodeRef>(map)); 1298 1307 return *this; … … 1305 1314 template <typename ANodeCrossRef> 1306 1315 BpUGraphCopy& aNodeCrossRef(ANodeCrossRef& map) { 1307 aNodeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy< Source,1316 aNodeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<From, 1308 1317 ANode, ANodeRefMap, ANodeCrossRef>(map)); 1309 1318 return *this; … … 1313 1322 /// 1314 1323 /// Makes copy of the given map for the newly created graph. 1315 /// The new map's key type is the t argetgraph's node type,1316 /// and the copied map's key type is the sourcegraph's node1324 /// The new map's key type is the to graph's node type, 1325 /// and the copied map's key type is the from graph's node 1317 1326 /// type. 1318 template <typename T argetMap, typename SourceMap>1319 BpUGraphCopy& aNodeMap(T argetMap& tmap, const SourceMap& map) {1320 aNodeMapCopies.push_back(new _graph_utils_bits::MapCopy< Source, ANode,1321 ANodeRefMap, T argetMap, SourceMap>(tmap, map));1327 template <typename ToMap, typename FromMap> 1328 BpUGraphCopy& aNodeMap(ToMap& tmap, const FromMap& map) { 1329 aNodeMapCopies.push_back(new _graph_utils_bits::MapCopy<From, ANode, 1330 ANodeRefMap, ToMap, FromMap>(tmap, map)); 1322 1331 return *this; 1323 1332 } … … 1328 1337 template <typename BNodeRef> 1329 1338 BpUGraphCopy& bNodeRef(BNodeRef& map) { 1330 bNodeMapCopies.push_back(new _graph_utils_bits::RefCopy< Source, BNode,1339 bNodeMapCopies.push_back(new _graph_utils_bits::RefCopy<From, BNode, 1331 1340 BNodeRefMap, BNodeRef>(map)); 1332 1341 return *this; … … 1339 1348 template <typename BNodeCrossRef> 1340 1349 BpUGraphCopy& bNodeCrossRef(BNodeCrossRef& map) { 1341 bNodeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy< Source,1350 bNodeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<From, 1342 1351 BNode, BNodeRefMap, BNodeCrossRef>(map)); 1343 1352 return *this; … … 1347 1356 /// 1348 1357 /// Makes copy of the given map for the newly created graph. 1349 /// The new map's key type is the t argetgraph's node type,1350 /// and the copied map's key type is the sourcegraph's node1358 /// The new map's key type is the to graph's node type, 1359 /// and the copied map's key type is the from graph's node 1351 1360 /// type. 1352 template <typename T argetMap, typename SourceMap>1353 BpUGraphCopy& bNodeMap(T argetMap& tmap, const SourceMap& map) {1354 bNodeMapCopies.push_back(new _graph_utils_bits::MapCopy< Source, BNode,1355 BNodeRefMap, T argetMap, SourceMap>(tmap, map));1361 template <typename ToMap, typename FromMap> 1362 BpUGraphCopy& bNodeMap(ToMap& tmap, const FromMap& map) { 1363 bNodeMapCopies.push_back(new _graph_utils_bits::MapCopy<From, BNode, 1364 BNodeRefMap, ToMap, FromMap>(tmap, map)); 1356 1365 return *this; 1357 1366 } … … 1361 1370 template <typename NodeRef> 1362 1371 BpUGraphCopy& nodeRef(NodeRef& map) { 1363 nodeMapCopies.push_back(new _graph_utils_bits::RefCopy< Source, Node,1372 nodeMapCopies.push_back(new _graph_utils_bits::RefCopy<From, Node, 1364 1373 NodeRefMap, NodeRef>(map)); 1365 1374 return *this; … … 1372 1381 template <typename NodeCrossRef> 1373 1382 BpUGraphCopy& nodeCrossRef(NodeCrossRef& map) { 1374 nodeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy< Source, Node,1383 nodeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<From, Node, 1375 1384 NodeRefMap, NodeCrossRef>(map)); 1376 1385 return *this; … … 1380 1389 /// 1381 1390 /// Makes copy of the given map for the newly created graph. 1382 /// The new map's key type is the t argetgraph's node type,1383 /// and the copied map's key type is the sourcegraph's node1391 /// The new map's key type is the to graph's node type, 1392 /// and the copied map's key type is the from graph's node 1384 1393 /// type. 1385 template <typename T argetMap, typename SourceMap>1386 BpUGraphCopy& nodeMap(T argetMap& tmap, const SourceMap& map) {1387 nodeMapCopies.push_back(new _graph_utils_bits::MapCopy< Source, Node,1388 NodeRefMap, T argetMap, SourceMap>(tmap, map));1394 template <typename ToMap, typename FromMap> 1395 BpUGraphCopy& nodeMap(ToMap& tmap, const FromMap& map) { 1396 nodeMapCopies.push_back(new _graph_utils_bits::MapCopy<From, Node, 1397 NodeRefMap, ToMap, FromMap>(tmap, map)); 1389 1398 return *this; 1390 1399 } … … 1394 1403 /// Make a copy of the given node. 1395 1404 BpUGraphCopy& node(TNode& tnode, const Node& snode) { 1396 nodeMapCopies.push_back(new _graph_utils_bits::ItemCopy< Source, Node,1405 nodeMapCopies.push_back(new _graph_utils_bits::ItemCopy<From, Node, 1397 1406 NodeRefMap, TNode>(tnode, snode)); 1398 1407 return *this; … … 1404 1413 template <typename EdgeRef> 1405 1414 BpUGraphCopy& edgeRef(EdgeRef& map) { 1406 edgeMapCopies.push_back(new _graph_utils_bits::RefCopy< Source, Edge,1415 edgeMapCopies.push_back(new _graph_utils_bits::RefCopy<From, Edge, 1407 1416 EdgeRefMap, EdgeRef>(map)); 1408 1417 return *this; … … 1415 1424 template <typename EdgeCrossRef> 1416 1425 BpUGraphCopy& edgeCrossRef(EdgeCrossRef& map) { 1417 edgeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy< Source, Edge,1426 edgeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<From, Edge, 1418 1427 EdgeRefMap, EdgeCrossRef>(map)); 1419 1428 return *this; … … 1423 1432 /// 1424 1433 /// Makes copy of the given map for the newly created graph. 1425 /// The new map's key type is the t argetgraph's edge type,1426 /// and the copied map's key type is the sourcegraph's edge1434 /// The new map's key type is the to graph's edge type, 1435 /// and the copied map's key type is the from graph's edge 1427 1436 /// type. 1428 template <typename T argetMap, typename SourceMap>1429 BpUGraphCopy& edgeMap(T argetMap& tmap, const SourceMap& map) {1430 edgeMapCopies.push_back(new _graph_utils_bits::MapCopy< Source, Edge,1431 EdgeRefMap, T argetMap, SourceMap>(tmap, map));1437 template <typename ToMap, typename FromMap> 1438 BpUGraphCopy& edgeMap(ToMap& tmap, const FromMap& map) { 1439 edgeMapCopies.push_back(new _graph_utils_bits::MapCopy<From, Edge, 1440 EdgeRefMap, ToMap, FromMap>(tmap, map)); 1432 1441 return *this; 1433 1442 } … … 1437 1446 /// Make a copy of the given edge. 1438 1447 BpUGraphCopy& edge(TEdge& tedge, const Edge& sedge) { 1439 edgeMapCopies.push_back(new _graph_utils_bits::ItemCopy< Source, Edge,1448 edgeMapCopies.push_back(new _graph_utils_bits::ItemCopy<From, Edge, 1440 1449 EdgeRefMap, TEdge>(tedge, sedge)); 1441 1450 return *this; … … 1447 1456 template <typename UEdgeRef> 1448 1457 BpUGraphCopy& uEdgeRef(UEdgeRef& map) { 1449 uEdgeMapCopies.push_back(new _graph_utils_bits::RefCopy< Source, UEdge,1458 uEdgeMapCopies.push_back(new _graph_utils_bits::RefCopy<From, UEdge, 1450 1459 UEdgeRefMap, UEdgeRef>(map)); 1451 1460 return *this; … … 1458 1467 template <typename UEdgeCrossRef> 1459 1468 BpUGraphCopy& uEdgeCrossRef(UEdgeCrossRef& map) { 1460 uEdgeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy< Source,1469 uEdgeMapCopies.push_back(new _graph_utils_bits::CrossRefCopy<From, 1461 1470 UEdge, UEdgeRefMap, UEdgeCrossRef>(map)); 1462 1471 return *this; … … 1466 1475 /// 1467 1476 /// Makes copy of the given map for the newly created graph. 1468 /// The new map's key type is the t argetgraph's undirected edge type,1469 /// and the copied map's key type is the sourcegraph's undirected edge1477 /// The new map's key type is the to graph's undirected edge type, 1478 /// and the copied map's key type is the from graph's undirected edge 1470 1479 /// type. 1471 template <typename T argetMap, typename SourceMap>1472 BpUGraphCopy& uEdgeMap(T argetMap& tmap, const SourceMap& map) {1473 uEdgeMapCopies.push_back(new _graph_utils_bits::MapCopy< Source, UEdge,1474 UEdgeRefMap, T argetMap, SourceMap>(tmap, map));1480 template <typename ToMap, typename FromMap> 1481 BpUGraphCopy& uEdgeMap(ToMap& tmap, const FromMap& map) { 1482 uEdgeMapCopies.push_back(new _graph_utils_bits::MapCopy<From, UEdge, 1483 UEdgeRefMap, ToMap, FromMap>(tmap, map)); 1475 1484 return *this; 1476 1485 } … … 1480 1489 /// Make a copy of the given undirected edge. 1481 1490 BpUGraphCopy& uEdge(TUEdge& tuedge, const UEdge& suedge) { 1482 uEdgeMapCopies.push_back(new _graph_utils_bits::ItemCopy< Source, UEdge,1491 uEdgeMapCopies.push_back(new _graph_utils_bits::ItemCopy<From, UEdge, 1483 1492 UEdgeRefMap, TUEdge>(tuedge, suedge)); 1484 1493 return *this; … … 1489 1498 /// Executes the copies. 1490 1499 void run() { 1491 ANodeRefMap aNodeRefMap( source);1492 BNodeRefMap bNodeRefMap( source);1493 NodeRefMap nodeRefMap( source, aNodeRefMap, bNodeRefMap);1494 UEdgeRefMap uEdgeRefMap( source);1495 EdgeRefMap edgeRefMap(t arget, source, uEdgeRefMap, nodeRefMap);1496 _graph_utils_bits::BpUGraphCopySelector<T arget>::1497 copy(t arget, source, aNodeRefMap, bNodeRefMap, uEdgeRefMap);1500 ANodeRefMap aNodeRefMap(from); 1501 BNodeRefMap bNodeRefMap(from); 1502 NodeRefMap nodeRefMap(from, aNodeRefMap, bNodeRefMap); 1503 UEdgeRefMap uEdgeRefMap(from); 1504 EdgeRefMap edgeRefMap(to, from, uEdgeRefMap, nodeRefMap); 1505 _graph_utils_bits::BpUGraphCopySelector<To>:: 1506 copy(to, from, aNodeRefMap, bNodeRefMap, uEdgeRefMap); 1498 1507 for (int i = 0; i < int(aNodeMapCopies.size()); ++i) { 1499 aNodeMapCopies[i]>copy( source, aNodeRefMap);1508 aNodeMapCopies[i]>copy(from, aNodeRefMap); 1500 1509 } 1501 1510 for (int i = 0; i < int(bNodeMapCopies.size()); ++i) { 1502 bNodeMapCopies[i]>copy( source, bNodeRefMap);1511 bNodeMapCopies[i]>copy(from, bNodeRefMap); 1503 1512 } 1504 1513 for (int i = 0; i < int(nodeMapCopies.size()); ++i) { 1505 nodeMapCopies[i]>copy( source, nodeRefMap);1514 nodeMapCopies[i]>copy(from, nodeRefMap); 1506 1515 } 1507 1516 for (int i = 0; i < int(uEdgeMapCopies.size()); ++i) { 1508 uEdgeMapCopies[i]>copy( source, uEdgeRefMap);1517 uEdgeMapCopies[i]>copy(from, uEdgeRefMap); 1509 1518 } 1510 1519 for (int i = 0; i < int(edgeMapCopies.size()); ++i) { 1511 edgeMapCopies[i]>copy( source, edgeRefMap);1520 edgeMapCopies[i]>copy(from, edgeRefMap); 1512 1521 } 1513 1522 } … … 1515 1524 private: 1516 1525 1517 const Source& source;1518 T arget& target;1519 1520 std::vector<_graph_utils_bits::MapCopyBase< Source, ANode, ANodeRefMap>* >1526 const From& from; 1527 To& to; 1528 1529 std::vector<_graph_utils_bits::MapCopyBase<From, ANode, ANodeRefMap>* > 1521 1530 aNodeMapCopies; 1522 1531 1523 std::vector<_graph_utils_bits::MapCopyBase< Source, BNode, BNodeRefMap>* >1532 std::vector<_graph_utils_bits::MapCopyBase<From, BNode, BNodeRefMap>* > 1524 1533 bNodeMapCopies; 1525 1534 1526 std::vector<_graph_utils_bits::MapCopyBase< Source, Node, NodeRefMap>* >1535 std::vector<_graph_utils_bits::MapCopyBase<From, Node, NodeRefMap>* > 1527 1536 nodeMapCopies; 1528 1537 1529 std::vector<_graph_utils_bits::MapCopyBase< Source, Edge, EdgeRefMap>* >1538 std::vector<_graph_utils_bits::MapCopyBase<From, Edge, EdgeRefMap>* > 1530 1539 edgeMapCopies; 1531 1540 1532 std::vector<_graph_utils_bits::MapCopyBase< Source, UEdge, UEdgeRefMap>* >1541 std::vector<_graph_utils_bits::MapCopyBase<From, UEdge, UEdgeRefMap>* > 1533 1542 uEdgeMapCopies; 1534 1543 … … 1545 1554 /// 1546 1555 /// After the copy the \c nr map will contain the mapping from the 1547 /// source graph's nodes to the targetgraph's nodes and the \c ecr will1548 /// contain the mapping from the t arget graph's edges to the source's1556 /// from graph's nodes to the to graph's nodes and the \c ecr will 1557 /// contain the mapping from the to graph's edges to the from's 1549 1558 /// edges. 1550 1559 /// 1551 1560 /// \see BpUGraphCopy 1552 template <typename T arget, typename Source>1553 BpUGraphCopy<T arget, Source>1554 copyBpUGraph(T arget& target, const Source& source) {1555 return BpUGraphCopy<T arget, Source>(target, source);1561 template <typename To, typename From> 1562 BpUGraphCopy<To, From> 1563 copyBpUGraph(To& to, const From& from) { 1564 return BpUGraphCopy<To, From>(to, from); 1556 1565 } 1557 1566
Note: See TracChangeset
for help on using the changeset viewer.