Merge bugfix in #250
authorAlpar Juttner <alpar@cs.elte.hu>
Mon, 12 Oct 2009 15:37:13 +0100
changeset 751f5f260a63a9b
parent 750 b7e3662faf02
parent 514 41bdb4d6c8c3
child 753 48fe2a46bf91
Merge bugfix in #250
lemon/path.h
     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