Update final step of decremental scc algorithm

This commit is contained in:
stefiosif
2022-06-29 17:58:52 +03:00
parent d199b7de17
commit 6b1edfa164

View File

@@ -19,6 +19,9 @@ public:
//
void init();
//
void findSCC();
//
bool query(const T& u, const T& v);
@@ -41,6 +44,11 @@ private:
template<typename T>
void DecrementalSCC<T>::init() {
findSCC();
}
template<typename T>
void DecrementalSCC<T>::findSCC() {
auto SCCs = Tarjan<T>(G).findSCC();
for (auto& C : SCCs) {
@@ -73,16 +81,21 @@ void DecrementalSCC<T>::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<T>(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<T>(G).findSCC();
}
}