From 5f39662235d63fb10b7f2cb451c1b1c7299ec36e Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Mon, 11 Jan 2021 13:18:59 +0100 Subject: [PATCH] Fix BFS visit --- libsolutil/Algorithms.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libsolutil/Algorithms.h b/libsolutil/Algorithms.h index 88d7310cb..6f8adebe5 100644 --- a/libsolutil/Algorithms.h +++ b/libsolutil/Algorithms.h @@ -106,11 +106,11 @@ struct BreadthFirstSearch V v = std::move(verticesToTraverse.front()); verticesToTraverse.pop_front(); - visited.insert(v); + if (!visited.insert(v).second) + continue; _forEachChild(v, [this](V _vertex) { - if (!visited.count(_vertex)) - verticesToTraverse.emplace_back(std::move(_vertex)); + verticesToTraverse.emplace_back(std::move(_vertex)); }); } return *this;