lemon/path_utils.h
changeset 97 ee1324c91288
parent 96 b55e501a90ee
equal deleted inserted replaced
0:a22df6f930a0 1:01419c53f253
    88     };
    88     };
    89 
    89 
    90   }
    90   }
    91 
    91 
    92 
    92 
    93   /// \brief Make of copy of a path.
    93   /// \brief Make a copy of a path.
    94   ///
    94   ///
    95   ///  Make of copy of a path.
    95   ///  This function makes a copy of a path.
    96   template <typename Target, typename Source>
    96   template <typename Target, typename Source>
    97   void copyPath(Target& target, const Source& source) {
    97   void copyPath(Target& target, const Source& source) {
    98     checkConcept<concepts::PathDumper<typename Source::Digraph>, Source>();
    98     checkConcept<concepts::PathDumper<typename Source::Digraph>, Source>();
    99     _path_bits::PathCopySelector<Target, Source>::copy(target, source);
    99     _path_bits::PathCopySelector<Target, Source>::copy(target, source);
   100   }
   100   }
   101 
   101 
   102   /// \brief Checks the path's consistency.
   102   /// \brief Check the consistency of a path.
   103   ///
   103   ///
   104   /// Checks that each arc's target is the next's source. 
   104   /// This function checks that the target of each arc is the same
       
   105   /// as the source of the next one. 
   105   /// 
   106   /// 
   106   template <typename Digraph, typename Path>
   107   template <typename Digraph, typename Path>
   107   bool checkPath(const Digraph& digraph, const Path& path) {
   108   bool checkPath(const Digraph& digraph, const Path& path) {
   108     typename Path::ArcIt it(path);
   109     typename Path::ArcIt it(path);
   109     if (it == INVALID) return true;
   110     if (it == INVALID) return true;
   115       ++it;
   116       ++it;
   116     }
   117     }
   117     return true;
   118     return true;
   118   }
   119   }
   119 
   120 
   120   /// \brief Gives back the source of the path
   121   /// \brief The source of a path
   121   ///
   122   ///
   122   /// Gives back the source of the path.
   123   /// This function returns the source of the given path.
   123   template <typename Digraph, typename Path>
   124   template <typename Digraph, typename Path>
   124   typename Digraph::Node pathSource(const Digraph& digraph, const Path& path) {
   125   typename Digraph::Node pathSource(const Digraph& digraph, const Path& path) {
   125     return digraph.source(path.front());
   126     return digraph.source(path.front());
   126   }
   127   }
   127 
   128 
   128   /// \brief Gives back the target of the path
   129   /// \brief The target of a path
   129   ///
   130   ///
   130   /// Gives back the target of the path.
   131   /// This function returns the target of the given path.
   131   template <typename Digraph, typename Path>
   132   template <typename Digraph, typename Path>
   132   typename Digraph::Node pathTarget(const Digraph& digraph, const Path& path) {
   133   typename Digraph::Node pathTarget(const Digraph& digraph, const Path& path) {
   133     return digraph.target(path.back());
   134     return digraph.target(path.back());
   134   }
   135   }
   135 
   136 
   136   /// \brief Class which helps to iterate the nodes of a path
   137   /// \brief Class which helps to iterate through the nodes of a path
   137   ///
   138   ///
   138   /// In a sense, the path can be treated as a list of arcs. The
   139   /// In a sense, the path can be treated as a list of arcs. The
   139   /// lemon path type stores just this list. As a consequence it
   140   /// lemon path type stores only this list. As a consequence, it
   140   /// cannot enumerate the nodes in the path and the zero length paths
   141   /// cannot enumerate the nodes in the path and the zero length paths
   141   /// cannot store the node.
   142   /// cannot have a source node.
   142   ///
   143   ///
   143   /// This class implements the node iterator of a path structure. To
   144   /// This class implements the node iterator of a path structure. To
   144   /// provide this feature, the underlying digraph should be given to
   145   /// provide this feature, the underlying digraph should be passed to
   145   /// the constructor of the iterator.
   146   /// the constructor of the iterator.
   146   template <typename Path>
   147   template <typename Path>
   147   class PathNodeIt {
   148   class PathNodeIt {
   148   private:
   149   private:
   149     const typename Path::Digraph *_digraph;
   150     const typename Path::Digraph *_digraph;