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

@@ -6,8 +6,7 @@
namespace algo {
template<typename T>
class King : public DynamicReachability<T> {
template <typename T> class King : public DynamicReachability<T> {
public:
King() = default;
@@ -19,26 +18,26 @@ public:
// Execute reachability query q(u, v) from vertex u to vertex v
// in O(n) using the stored decremental maintenance data structure for DAGs
bool query(const T& u, const T& v) override;
bool query(const T &u, const T &v) override;
// Delete collection of edges
void remove(const std::vector<std::pair<T, T>>& edges) override;
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);
void remove(const T &u, const T &v);
// Insert edge e(u, v) by reconstructing all reachability trees
void insert(const T& c, const std::vector<T>& vertices) 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;
std::unordered_map<T, Italiano<T>> Out;
};
template<typename T>
void King<T>::init() {
for (const auto& u : this->G.vertices()) {
template <typename T> void King<T>::init() {
for (const auto &u : this->G.vertices()) {
In[u] = Italiano<T>(BreadthFirstTree<T>(this->G.reverse(), u));
In[u].init();
Out[u] = Italiano<T>(BreadthFirstTree<T>(this->G, u));
@@ -46,32 +45,29 @@ void King<T>::init() {
}
}
template<typename T>
bool King<T>::query(const T& u, const T& v) {
return std::ranges::any_of(this->G.vertices().begin(), this->G.vertices().end(),
[&](const T& w) {
return In[w].query(w, u) && Out[w].query(w, v);
});
template <typename T> bool King<T>::query(const T &u, const T &v) {
return std::any_of(
this->G.vertices().begin(), this->G.vertices().end(),
[&](const T &w) { return In[w].query(w, u) && Out[w].query(w, v); });
}
template<typename T>
void King<T>::remove(const std::vector<std::pair<T, T>>& edges) {
for (const auto& [u, v] : edges)
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) {
template <typename T> void King<T>::remove(const T &u, const T &v) {
this->G.remove(u, v);
for (const auto& w : this->G.vertices()) {
for (const auto &w : this->G.vertices()) {
In[w].remove(v, u);
Out[w].remove(u, v);
}
}
template<typename T>
void King<T>::insert(const T& c, const std::vector<T>& vertices) {
for (const auto& v : vertices) {
template <typename T>
void King<T>::insert(const T &c, const std::vector<T> &vertices) {
for (const auto &v : vertices) {
this->G.insert(c, v);
}
In[c] = Italiano<T>(BreadthFirstTree<T>(this->G.reverse(), c));