From 82978f4357b163c59e08a9f5c5fc8410550f1cd1 Mon Sep 17 00:00:00 2001 From: Sebastian Junges Date: Tue, 14 Apr 2020 10:34:45 -0700 Subject: [PATCH] isSinkState --- src/storm/models/sparse/Model.cpp | 11 ++++++++++- src/storm/models/sparse/Model.h | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/storm/models/sparse/Model.cpp b/src/storm/models/sparse/Model.cpp index 6e087822f..b7dc39dd5 100644 --- a/src/storm/models/sparse/Model.cpp +++ b/src/storm/models/sparse/Model.cpp @@ -412,7 +412,16 @@ namespace storm { void Model::setTransitionMatrix(storm::storage::SparseMatrix&& transitionMatrix) { this->transitionMatrix = std::move(transitionMatrix); } - + + template + bool Model::isSinkState(uint64_t state) const { + for (auto const& entry : this->getTransitionMatrix().getRowGroup(state)) { + if (entry.getColumn() != state) { return false; } + if (storm::utility::isOne(entry.getValue())) { return false; } + } + return true; + } + template bool Model::isSparseModel() const { return true; diff --git a/src/storm/models/sparse/Model.h b/src/storm/models/sparse/Model.h index d1ef45bc1..4b8616f8a 100644 --- a/src/storm/models/sparse/Model.h +++ b/src/storm/models/sparse/Model.h @@ -318,6 +318,8 @@ namespace storm { * @param out The stream the information is to be printed to. */ virtual void printModelInformationToStream(std::ostream& out) const override; + + bool isSinkState(uint64_t sink) const; /*! * Exports the model to the dot-format and prints the result to the given stream.