Merge bugfix in #250 1.1
authorAlpar Juttner <alpar@cs.elte.hu>
Mon, 12 Oct 2009 15:30:18 +0100
branch1.1
changeset 856c05bb175d3ee
parent 855 1db9f9db4f95
parent 548 41bdb4d6c8c3
child 857 989c6629d045
Merge bugfix in #250
lemon/path.h
     1.1 --- a/lemon/path.h	Mon Oct 05 20:21:31 2009 +0200
     1.2 +++ b/lemon/path.h	Mon Oct 12 15:30:18 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