Fix bug that would make ids connect to a different component

This commit is contained in:
stefiosif
2022-09-21 19:30:26 +03:00
parent 7d2d9fd82c
commit 7345a28945

View File

@@ -28,6 +28,7 @@ private:
std::stack<T> S;
std::int16_t index = 0;
std::vector<SCC<T>> SCCs;
T cid;
struct Vertex {
int index = -1;
@@ -56,6 +57,7 @@ void Tarjan<T>::strongConnect(const T& u) {
if (vmap[u].lowlink == vmap[u].index) {
std::map<T, std::set<T>> scc;
bool finished = false;
cid = S.top();
do {
const auto w = S.top();
@@ -65,7 +67,7 @@ void Tarjan<T>::strongConnect(const T& u) {
finished = (w == u);
} while (!finished);
SCCs.push_back({ scc, static_cast<T>(vmap[u].lowlink + 1) });
SCCs.push_back({ scc, static_cast<T>(cid) });
}
}