556 return this->graph->head(e); } |
556 return this->graph->head(e); } |
557 Node bNode(const OutEdgeIt& e) const { |
557 Node bNode(const OutEdgeIt& e) const { |
558 if (e.out_or_in) return this->graph->head(e); else |
558 if (e.out_or_in) return this->graph->head(e); else |
559 return this->graph->tail(e); } |
559 return this->graph->tail(e); } |
560 |
560 |
561 KEEP_MAPS(Parent, UndirGraphWrapper); |
561 // KEEP_MAPS(Parent, UndirGraphWrapper); |
562 |
562 |
563 }; |
563 }; |
564 |
564 |
565 /// \brief An undirected graph template. |
565 /// \brief An undirected graph template. |
566 /// |
566 /// |
567 ///\warning Graph wrappers are in even more experimental state than the other |
567 ///\warning Graph wrappers are in even more experimental state than the other |
568 ///parts of the lib. Use them at you own risk. |
568 ///parts of the lib. Use them at your own risk. |
569 /// |
569 /// |
570 /// An undirected graph template. |
570 /// An undirected graph template. |
571 /// This class works as an undirected graph and a directed graph of |
571 /// This class works as an undirected graph and a directed graph of |
572 /// class \c Graph is used for the physical storage. |
572 /// class \c Graph is used for the physical storage. |
573 /// \ingroup graphs |
573 /// \ingroup graphs |
892 template <typename T> |
892 template <typename T> |
893 /// \c SubBidirGraphWrapper<..., ..., ...>::EdgeMap contains two |
893 /// \c SubBidirGraphWrapper<..., ..., ...>::EdgeMap contains two |
894 /// Graph::EdgeMap one for the forward edges and |
894 /// Graph::EdgeMap one for the forward edges and |
895 /// one for the backward edges. |
895 /// one for the backward edges. |
896 class EdgeMap { |
896 class EdgeMap { |
|
897 template <typename TT> friend class EdgeMap; |
897 typename Graph::template EdgeMap<T> forward_map, backward_map; |
898 typename Graph::template EdgeMap<T> forward_map, backward_map; |
898 public: |
899 public: |
899 typedef T ValueType; |
900 typedef T ValueType; |
900 typedef Edge KeyType; |
901 typedef Edge KeyType; |
|
902 |
901 EdgeMap(const SubBidirGraphWrapper<Graph, |
903 EdgeMap(const SubBidirGraphWrapper<Graph, |
902 ForwardFilterMap, BackwardFilterMap>& g) : |
904 ForwardFilterMap, BackwardFilterMap>& g) : |
903 forward_map(*(g.graph)), backward_map(*(g.graph)) { } |
905 forward_map(*(g.graph)), backward_map(*(g.graph)) { } |
|
906 |
904 EdgeMap(const SubBidirGraphWrapper<Graph, |
907 EdgeMap(const SubBidirGraphWrapper<Graph, |
905 ForwardFilterMap, BackwardFilterMap>& g, T a) : |
908 ForwardFilterMap, BackwardFilterMap>& g, T a) : |
906 forward_map(*(g.graph), a), backward_map(*(g.graph), a) { } |
909 forward_map(*(g.graph), a), backward_map(*(g.graph), a) { } |
|
910 |
|
911 template <typename TT> |
|
912 EdgeMap(const EdgeMap<TT>& copy) |
|
913 : forward_map(copy.forward_map), backward_map(copy.backward_map) {} |
|
914 |
|
915 template <typename TT> |
|
916 EdgeMap& operator=(const EdgeMap<TT>& copy) { |
|
917 forward_map = copy.forward_map; |
|
918 backward_map = copy.backward_map; |
|
919 return *this; |
|
920 } |
|
921 |
907 void set(Edge e, T a) { |
922 void set(Edge e, T a) { |
908 if (!e.backward) |
923 if (!e.backward) |
909 forward_map.set(e, a); |
924 forward_map.set(e, a); |
910 else |
925 else |
911 backward_map.set(e, a); |
926 backward_map.set(e, a); |
912 } |
927 } |
913 T operator[](Edge e) const { |
928 |
|
929 typename Graph::template EdgeMap<T>::ConstReferenceType |
|
930 operator[](Edge e) const { |
914 if (!e.backward) |
931 if (!e.backward) |
915 return forward_map[e]; |
932 return forward_map[e]; |
916 else |
933 else |
917 return backward_map[e]; |
934 return backward_map[e]; |
918 } |
935 } |
|
936 |
|
937 typename Graph::template EdgeMap<T>::ReferenceType |
|
938 operator[](Edge e) { |
|
939 if (!e.backward) |
|
940 return forward_map[e]; |
|
941 else |
|
942 return backward_map[e]; |
|
943 } |
|
944 |
919 void update() { |
945 void update() { |
920 forward_map.update(); |
946 forward_map.update(); |
921 backward_map.update(); |
947 backward_map.update(); |
922 } |
948 } |
923 }; |
949 }; |
924 |
950 |
925 |
951 |
926 KEEP_NODE_MAP(Parent, SubBidirGraphWrapper); |
952 // KEEP_NODE_MAP(Parent, SubBidirGraphWrapper); |
927 |
953 |
928 }; |
954 }; |
929 |
955 |
930 |
956 |
931 ///\brief A wrapper for composing bidirected graph from a directed one. |
957 ///\brief A wrapper for composing bidirected graph from a directed one. |