diff --git a/algorithm/decremental_scc.h b/algorithm/decremental_scc.h index 6cc447c..b91f36d 100644 --- a/algorithm/decremental_scc.h +++ b/algorithm/decremental_scc.h @@ -19,6 +19,9 @@ public: // void init(); + // + void findSCC(); + // bool query(const T& u, const T& v); @@ -41,6 +44,11 @@ private: template void DecrementalSCC::init() { + findSCC(); +} + +template +void DecrementalSCC::findSCC() { auto SCCs = Tarjan(G).findSCC(); for (auto& C : SCCs) { @@ -73,16 +81,21 @@ void DecrementalSCC::remove(const T& u, const T& v) { // If edge e(u, v) is not contained in In(w) and Out(w), do nothing if (!SPT[w].first.vertices.contains(w) && - !SPT[w].second.vertices.contains(w)) + !SPT[w].second.vertices.contains(w)){ + connection[w].adjMatrix[u].erase(v); + G.adjMatrix[u].erase(v); return; - + } // Update In(w) and Out(w) + connection[w].adjMatrix[u].erase(v); + G.adjMatrix[u].erase(v); auto inTree = BFS(connection[w]).run(w); SPT[w] = std::make_pair(inTree, inTree.reverse()); + // If a SCC is broken, compute all SCCs again if (!SPT[w].second.vertices.contains(u) || !SPT[w].first.vertices.contains(v)) { - // TODO: Decompose C into C1, C2, ... Ck + auto SCCs = Tarjan(G).findSCC(); } }