From 374f7e1fbb121a7a69e63a9d7b842450844e1625 Mon Sep 17 00:00:00 2001 From: Tom Janson Date: Mon, 30 Oct 2017 17:02:37 +0100 Subject: [PATCH] kSP: disallow access to index 0 (1-based indices!) --- src/storm/utility/shortestPaths.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/storm/utility/shortestPaths.cpp b/src/storm/utility/shortestPaths.cpp index c2f6a97b9..8432ce1a5 100644 --- a/src/storm/utility/shortestPaths.cpp +++ b/src/storm/utility/shortestPaths.cpp @@ -11,7 +11,6 @@ #include "storm/utility/shortestPaths.h" // FIXME: I've accidentally used k=0 *twice* now without realizing that k>=1 is required! -// Accessing zero should trigger a warning! // (Also, did I document this? I think so, somewhere. I went with k>=1 because // that's what the KSP paper used, but in retrospect k>=0 seems more intuitive ...) @@ -336,6 +335,10 @@ namespace storm { template void ShortestPathsGenerator::computeKSP(unsigned long k) { + if (k == 0) { + throw std::invalid_argument("Index 0 is invalid, since we use 1-based indices (sorry)!"); + } + unsigned long alreadyComputedK = kShortestPaths[metaTarget].size(); for (unsigned long nextK = alreadyComputedK + 1; nextK <= k; nextK++) {