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) }); } }