359 typedef typename Map::ConstReference ConstReference; |
359 typedef typename Map::ConstReference ConstReference; |
360 typedef typename Map::Pointer Pointer; |
360 typedef typename Map::Pointer Pointer; |
361 typedef typename Map::ConstPointer ConstPointer; |
361 typedef typename Map::ConstPointer ConstPointer; |
362 }; |
362 }; |
363 |
363 |
364 |
|
365 /// Provides an immutable and unique id for each item in the graph. |
364 /// Provides an immutable and unique id for each item in the graph. |
366 |
365 |
367 /// The IdMap class provides an unique and immutable mapping for each item |
366 /// The IdMap class provides an unique and immutable mapping for each item |
368 /// in the graph. |
367 /// in the graph. |
369 /// |
368 /// |
691 /// The SourceMap gives back the source Node of the given edge. |
695 /// The SourceMap gives back the source Node of the given edge. |
692 /// \author Balazs Dezso |
696 /// \author Balazs Dezso |
693 template <typename Graph> |
697 template <typename Graph> |
694 class SourceMap { |
698 class SourceMap { |
695 public: |
699 public: |
|
700 |
|
701 typedef True NeedCopy; |
|
702 |
696 typedef typename Graph::Node Value; |
703 typedef typename Graph::Node Value; |
697 typedef typename Graph::Edge Key; |
704 typedef typename Graph::Edge Key; |
698 |
705 |
699 /// \brief Constructor |
706 /// \brief Constructor |
700 /// |
707 /// |
729 /// The TargetMap gives back the target Node of the given edge. |
736 /// The TargetMap gives back the target Node of the given edge. |
730 /// \author Balazs Dezso |
737 /// \author Balazs Dezso |
731 template <typename Graph> |
738 template <typename Graph> |
732 class TargetMap { |
739 class TargetMap { |
733 public: |
740 public: |
|
741 |
|
742 typedef True NeedCopy; |
|
743 |
734 typedef typename Graph::Node Value; |
744 typedef typename Graph::Node Value; |
735 typedef typename Graph::Edge Key; |
745 typedef typename Graph::Edge Key; |
736 |
746 |
737 /// \brief Constructor |
747 /// \brief Constructor |
738 /// |
748 /// |
760 template <typename Graph> |
770 template <typename Graph> |
761 inline TargetMap<Graph> targetMap(const Graph& graph) { |
771 inline TargetMap<Graph> targetMap(const Graph& graph) { |
762 return TargetMap<Graph>(graph); |
772 return TargetMap<Graph>(graph); |
763 } |
773 } |
764 |
774 |
|
775 /// \brief Returns the "forward" directed edge view of undirected edge. |
|
776 /// |
|
777 /// Returns the "forward" directed edge view of undirected edge. |
|
778 /// \author Balazs Dezso |
|
779 template <typename Graph> |
|
780 class ForwardMap { |
|
781 public: |
|
782 |
|
783 typedef True NeedCopy; |
|
784 |
|
785 typedef typename Graph::Edge Value; |
|
786 typedef typename Graph::UndirEdge Key; |
|
787 |
|
788 /// \brief Constructor |
|
789 /// |
|
790 /// Constructor |
|
791 /// \param _graph The graph that the map belongs to. |
|
792 ForwardMap(const Graph& _graph) : graph(_graph) {} |
|
793 |
|
794 /// \brief The subscript operator. |
|
795 /// |
|
796 /// The subscript operator. |
|
797 /// \param key An undirected edge |
|
798 /// \return The "forward" directed edge view of undirected edge |
|
799 Value operator[](const Key& key) const { |
|
800 return graph.edgeWithSource(key, graph.source(key)); |
|
801 } |
|
802 |
|
803 private: |
|
804 const Graph& graph; |
|
805 }; |
|
806 |
|
807 /// \brief Returns a \ref ForwardMap class |
|
808 |
|
809 /// This function just returns an \ref ForwardMap class. |
|
810 /// \relates ForwardMap |
|
811 template <typename Graph> |
|
812 inline ForwardMap<Graph> forwardMap(const Graph& graph) { |
|
813 return ForwardMap<Graph>(graph); |
|
814 } |
|
815 |
|
816 /// \brief Returns the "backward" directed edge view of undirected edge. |
|
817 /// |
|
818 /// Returns the "backward" directed edge view of undirected edge. |
|
819 /// \author Balazs Dezso |
|
820 template <typename Graph> |
|
821 class BackwardMap { |
|
822 public: |
|
823 typedef True NeedCopy; |
|
824 |
|
825 typedef typename Graph::Edge Value; |
|
826 typedef typename Graph::UndirEdge Key; |
|
827 |
|
828 /// \brief Constructor |
|
829 /// |
|
830 /// Constructor |
|
831 /// \param _graph The graph that the map belongs to. |
|
832 BackwardMap(const Graph& _graph) : graph(_graph) {} |
|
833 |
|
834 /// \brief The subscript operator. |
|
835 /// |
|
836 /// The subscript operator. |
|
837 /// \param key An undirected edge |
|
838 /// \return The "backward" directed edge view of undirected edge |
|
839 Value operator[](const Key& key) const { |
|
840 return graph.edgeWithSource(key, graph.target(key)); |
|
841 } |
|
842 |
|
843 private: |
|
844 const Graph& graph; |
|
845 }; |
|
846 |
|
847 /// \brief Returns a \ref BackwardMap class |
|
848 |
|
849 /// This function just returns an \ref BackwardMap class. |
|
850 /// \relates BackwardMap |
|
851 template <typename Graph> |
|
852 inline BackwardMap<Graph> backwardMap(const Graph& graph) { |
|
853 return BackwardMap<Graph>(graph); |
|
854 } |
|
855 |
765 |
856 |
766 /// @} |
857 /// @} |
767 |
858 |
768 } //END OF NAMESPACE LEMON |
859 } //END OF NAMESPACE LEMON |
769 |
860 |