Fix bug that would make ids connect to a different component
This commit is contained in:
@@ -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) });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user