Refactor: Split remove into remove/repairTrees

This commit is contained in:
stefiosif
2022-09-29 23:47:36 +03:00
parent 371104a337
commit a1f955ebb9

View File

@@ -39,6 +39,9 @@ private:
std::set<T> out; std::set<T> out;
}; };
std::map<T, Edges> E; std::map<T, Edges> E;
// Repair reachability trees after edge deletions
void repairTrees(std::map<T, std::stack<T>>& H);
}; };
template<typename T> template<typename T>
@@ -82,6 +85,11 @@ void Italiano<T>::remove(const T& u, const T& v) {
E[v].inc.erase(u); E[v].inc.erase(u);
this->G.remove(u, v); this->G.remove(u, v);
repairTrees(H);
}
template<typename T>
void Italiano<T>::repairTrees(std::map<T, std::stack<T>>& H) {
for (const auto& z : this->G.vertices()) { for (const auto& z : this->G.vertices()) {
while (H[z].size() > 0) { while (H[z].size() > 0) {
const auto& h = H[z].top(); const auto& h = H[z].top();