[Lemon-commits] Alpar Juttner: Merge bugfix in #250
Lemon HG
hg at lemon.cs.elte.hu
Mon Oct 12 16:44:04 CEST 2009
details: http://lemon.cs.elte.hu/hg/lemon/rev/f5f260a63a9b
changeset: 810:f5f260a63a9b
user: Alpar Juttner <alpar [at] cs.elte.hu>
date: Mon Oct 12 15:37:13 2009 +0100
description:
Merge bugfix in #250
diffstat:
lemon/path.h | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diffs (28 lines):
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, typename Path>
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, typename Path>
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
More information about the Lemon-commits
mailing list