Refactor: Change reachability interfaces to handle multiple removals/insertions
This commit is contained in:
@@ -23,12 +23,15 @@ public:
|
||||
// in O(n) using the stored decremental maintenance data structure for DAGs
|
||||
bool query(const T& u, const T& v) override;
|
||||
|
||||
// Delete collection of edges
|
||||
void remove(const std::vector<std::pair<T, T>>& edges) override;
|
||||
|
||||
// Delete edge e(u, v) from all reachability trees and update each one of
|
||||
// them using the decremental reachability algorithm for DAGs
|
||||
void remove(const T& u, const T& v) override;
|
||||
void remove(const T& u, const T& v);
|
||||
|
||||
// Insert edge e(u, v) by reconstructing all reachability trees
|
||||
void insert(const T& u, const T& v) override;
|
||||
void insert(const T& c, const std::vector<T>& vertices) override;
|
||||
private:
|
||||
// Connect each reachabiliy tree with decremental maintenance data structure
|
||||
std::unordered_map<T, Italiano<T>> In;
|
||||
@@ -53,6 +56,12 @@ bool King<T>::query(const T& u, const T& v) {
|
||||
});
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void King<T>::remove(const std::vector<std::pair<T, T>>& edges) {
|
||||
for (const auto& [u, v] : edges)
|
||||
remove(u, v);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void King<T>::remove(const T& u, const T& v) {
|
||||
this->G.remove(u, v);
|
||||
@@ -63,8 +72,9 @@ void King<T>::remove(const T& u, const T& v) {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void King<T>::insert(const T& u, const T& v) {
|
||||
this->G.insert(u, v);
|
||||
void King<T>::insert(const T& c, const std::vector<T>& vertices) {
|
||||
for (const auto& v : vertices)
|
||||
this->G.insert(c, v);
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user