Update final step of decremental scc algorithm
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user