Use clang-format

This commit is contained in:
stefiosif
2024-08-03 13:14:42 +03:00
parent d216a9611f
commit 3951db7ff9
17 changed files with 262 additions and 287 deletions

View File

@@ -8,8 +8,7 @@ constexpr int threshold = 5;
namespace algo {
template<typename T>
class HenzingerKing : public DynamicReachability<T> {
template <typename T> class HenzingerKing : public DynamicReachability<T> {
public:
HenzingerKing() = default;
@@ -21,16 +20,17 @@ public:
// Execute query q(u, v) from vertex u to vertex v by querying the
// decremental reachability data structure at the start of the phase
// and then if necessary check the set S
bool query(const T& u, const T& v) override;
bool query(const T &u, const T &v) override;
// Remove collection of edges from the decremental maintenance data structure
// and for every vertex in set S, rebuilt reachability trees from scratch
void remove(const std::vector<std::pair<T,T>>& edges);
void remove(const std::vector<std::pair<T, T>> &edges) override;
// Insert collection of edges in set S, if threshold is reached re-initialize
// algorithm, otherwise construct reachability trees for the vertex that is
// the center-of-insertions
void insert(const T& c, const std::vector<T>& vertices);
void insert(const T &c, const std::vector<T> &vertices) override;
private:
// Decremental maintenance data structure
Frigioni<T> frigioni;
@@ -43,41 +43,37 @@ private:
std::unordered_map<T, BreadthFirstTree<T>> Out;
};
template<typename T>
void HenzingerKing<T>::init() {
template <typename T> void HenzingerKing<T>::init() {
S.clear();
frigioni = Frigioni<T>(this->G);
frigioni.init();
}
template<typename T>
bool HenzingerKing<T>::query(const T& u, const T& v) {
template <typename T> bool HenzingerKing<T>::query(const T &u, const T &v) {
if (frigioni.query(u, v))
return true;
return std::ranges::any_of(S.begin(), S.end(),
[&](const T& w) {
return In[w].adjList.contains(u) &&
Out[w].adjList.contains(v);
});
return std::ranges::any_of(S.begin(), S.end(), [&](const T &w) {
return In[w].adjList.contains(u) && Out[w].adjList.contains(v);
});
}
template<typename T>
void HenzingerKing<T>::remove(const std::vector<std::pair<T, T>>& edges) {
for (const auto& [u, v] : edges) {
template <typename T>
void HenzingerKing<T>::remove(const std::vector<std::pair<T, T>> &edges) {
for (const auto &[u, v] : edges) {
this->G.remove(u, v);
}
frigioni.remove(edges);
for (const auto& w : S) {
for (const auto &w : S) {
In[w] = BreadthFirstTree(this->G.reverse(), w);
Out[w] = BreadthFirstTree(this->G, w);
}
}
template<typename T>
void HenzingerKing<T>::insert(const T& c, const std::vector<T>& vertices) {
for (const auto& w : vertices)
template <typename T>
void HenzingerKing<T>::insert(const T &c, const std::vector<T> &vertices) {
for (const auto &w : vertices)
this->G.insert(c, w);
S.insert(c);