# HG changeset patch # User Peter Kovacs # Date 2009-10-12 13:41:15 # Node ID 41bdb4d6c8c32c29a1eaebc3eef9bef7ef1f9862 # Parent 32fb28fc9d4298c95033cd2d41e634757d6952b4 Fix in pathSource() and pathTarget() (#250) and extend the doc. diff --git a/lemon/path.h b/lemon/path.h --- a/lemon/path.h +++ b/lemon/path.h @@ -1015,18 +1015,20 @@ /// \brief The source of a path /// - /// This function returns the source of the given path. + /// This function returns the source node of the given path. + /// If the path is empty, then it returns \c INVALID. template typename Digraph::Node pathSource(const Digraph& digraph, const Path& path) { - return digraph.source(path.front()); + return path.empty() ? INVALID : digraph.source(path.front()); } /// \brief The target of a path /// - /// This function returns the target of the given path. + /// This function returns the target node of the given path. + /// If the path is empty, then it returns \c INVALID. template typename Digraph::Node pathTarget(const Digraph& digraph, const Path& path) { - return digraph.target(path.back()); + return path.empty() ? INVALID : digraph.target(path.back()); } /// \brief Class which helps to iterate through the nodes of a path