1.1 --- a/lemon/path.h Mon Oct 05 20:21:54 2009 +0200
1.2 +++ b/lemon/path.h Mon Oct 12 15:37:13 2009 +0100
1.3 @@ -1015,18 +1015,20 @@
1.4
1.5 /// \brief The source of a path
1.6 ///
1.7 - /// This function returns the source of the given path.
1.8 + /// This function returns the source node of the given path.
1.9 + /// If the path is empty, then it returns \c INVALID.
1.10 template <typename Digraph, typename Path>
1.11 typename Digraph::Node pathSource(const Digraph& digraph, const Path& path) {
1.12 - return digraph.source(path.front());
1.13 + return path.empty() ? INVALID : digraph.source(path.front());
1.14 }
1.15
1.16 /// \brief The target of a path
1.17 ///
1.18 - /// This function returns the target of the given path.
1.19 + /// This function returns the target node of the given path.
1.20 + /// If the path is empty, then it returns \c INVALID.
1.21 template <typename Digraph, typename Path>
1.22 typename Digraph::Node pathTarget(const Digraph& digraph, const Path& path) {
1.23 - return digraph.target(path.back());
1.24 + return path.empty() ? INVALID : digraph.target(path.back());
1.25 }
1.26
1.27 /// \brief Class which helps to iterate through the nodes of a path