Refactor: Change reachability interfaces to handle multiple removals/insertions
This commit is contained in:
@@ -25,8 +25,11 @@ public:
|
||||
// Return true if u and v are in the same SCC
|
||||
bool query(const T& u, const T& v) override;
|
||||
|
||||
// Delete collection of edges
|
||||
void remove(const std::vector<std::pair<T, T>>& edges) override;
|
||||
|
||||
// Remove edge (u,v) and update A accordingly for fast checking query
|
||||
void remove(const T& u, const T& v) override;
|
||||
void remove(const T& u, const T& v);
|
||||
|
||||
std::unordered_map<T, SCC<T>> getSCCs() { return C; }
|
||||
private:
|
||||
@@ -68,6 +71,12 @@ bool RodittyZwick<T>::query(const T& u, const T& v) {
|
||||
return A[u] == A[v];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void RodittyZwick<T>::remove(const std::vector<std::pair<T, T>>& edges) {
|
||||
for (const auto& [u, v] : edges)
|
||||
remove(u, v);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void RodittyZwick<T>::remove(const T& u, const T& v) {
|
||||
const auto& w = A[u];
|
||||
|
||||
Reference in New Issue
Block a user