Add dynamic RZ algorithms inspired by King and Henzinger

This commit is contained in:
stefiosif
2022-09-25 17:41:17 +03:00
parent fa65e54376
commit d63411672d
2 changed files with 152 additions and 0 deletions

View File

@@ -0,0 +1,79 @@
#ifndef HENZINGER_KING_H_
#define HENZINGER_KING_H_
#include "algorithm/dynamic_reachability.h"
#include "algorithm/frigioni.h"
using namespace graph;
namespace algo {
template<typename T>
class HenzingerKing : public DynamicReachability<T> {
public:
HenzingerKing() = default;
HenzingerKing(Digraph<T> G) { this->G = G; }
// 1. Initialize a decremental reachability data structure.
// 2. Let S <- phi.
// In the beginning of each phase, a decremental reachability data structure
// is initialized. We let S be the set of vertices that were centers of
// insertions during this phase. Initially S = phi. When a set of edges Ev, all
// touching v, is inserted, we add v to S and construct reachability trees In(v)
// and Out(v) rooted at v. When the size of S, the set of insertion centers,
// reaches t, a parameter fixed in advance, the phase is declared over, and
// all the data structures are reinitialized.
void init() override;
// 1. Query the decremental reachability data structure.
// 2. For each w in S check if u in In(w) and v in Out(w).
// First the decremental data structure is queried to see whether there is a
// directed path from u to v composed solely of edges that were present in the
// graph at the start of the current phase. If not, it is checked whether there
// exists w in S such that u in In(w) and v in Out(w). If such a vertex w exists,
// then the answer is YES.
bool query(const T& u, const T& v) override;
// 1. Let E <- E - E'.
// 2. Delete E' from the decremental data structure.
// 3. For every w in S, rebuilt the trees In(w) and Out(w).
// First, the edges of E' are removed from the decremental data structure. Next,
// for every w in S, the shortest-paths trees In(w) and Out(w) are built from
// scratch.
void remove(const T& u, const T& v) override;
// 1. Let E <- E union Ev.
// 2. Let S <- S union {v}.
// 3. If |S| > t, then call init.
// 4. Otherwise, construct the trees In(v) and Out(v).
void insert(const T& u, const T& v) override;
};
template<typename T>
void HenzingerKing<T>::init() {
}
template<typename T>
bool HenzingerKing<T>::query(const T& u, const T& v) {
return false;
}
template<typename T>
void HenzingerKing<T>::remove(const T& u, const T& v) {
}
template<typename T>
void HenzingerKing<T>::insert(const T& u, const T& v) {
}
} // namespace algo
#endif