From 7345a28945ae5ced9f1a36df2bc99c7fe5eba954 Mon Sep 17 00:00:00 2001 From: stefiosif Date: Wed, 21 Sep 2022 19:30:26 +0300 Subject: [PATCH] Fix bug that would make ids connect to a different component --- algorithm/tarjan.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/algorithm/tarjan.h b/algorithm/tarjan.h index f0e0245..1fd1864 100644 --- a/algorithm/tarjan.h +++ b/algorithm/tarjan.h @@ -28,6 +28,7 @@ private: std::stack S; std::int16_t index = 0; std::vector> SCCs; + T cid; struct Vertex { int index = -1; @@ -56,6 +57,7 @@ void Tarjan::strongConnect(const T& u) { if (vmap[u].lowlink == vmap[u].index) { std::map> scc; bool finished = false; + cid = S.top(); do { const auto w = S.top(); @@ -65,7 +67,7 @@ void Tarjan::strongConnect(const T& u) { finished = (w == u); } while (!finished); - SCCs.push_back({ scc, static_cast(vmap[u].lowlink + 1) }); + SCCs.push_back({ scc, static_cast(cid) }); } }