Use clang-format
This commit is contained in:
@@ -7,8 +7,7 @@
|
||||
|
||||
namespace algo {
|
||||
|
||||
template<typename T>
|
||||
class RodittyZwick : public DecrementalReachability<T> {
|
||||
template <typename T> class RodittyZwick : public DecrementalReachability<T> {
|
||||
public:
|
||||
RodittyZwick() = default;
|
||||
|
||||
@@ -21,15 +20,16 @@ public:
|
||||
void findSCC(graph::Digraph<T> G);
|
||||
|
||||
// Return true if u and v are in the same SCC
|
||||
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;
|
||||
|
||||
// Remove edge (u,v) and update A accordingly for fast checking query
|
||||
void remove(const T& u, const T& v);
|
||||
void remove(const T &u, const T &v);
|
||||
|
||||
std::unordered_map<T, SCC<T>> getComponentMap() { return C; }
|
||||
|
||||
private:
|
||||
// Array used to answer strong connectivity queries in O(1) time
|
||||
std::unordered_map<T, T> A;
|
||||
@@ -42,21 +42,17 @@ private:
|
||||
std::unordered_map<T, BreadthFirstTree<T>> Out;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
void RodittyZwick<T>::init() {
|
||||
findSCC(this->G);
|
||||
}
|
||||
template <typename T> void RodittyZwick<T>::init() { findSCC(this->G); }
|
||||
|
||||
template<typename T>
|
||||
void RodittyZwick<T>::findSCC(graph::Digraph<T> G) {
|
||||
template <typename T> void RodittyZwick<T>::findSCC(graph::Digraph<T> G) {
|
||||
auto SCCs = Tarjan<T>(G.adjList).execute();
|
||||
|
||||
for (auto& c : SCCs) {
|
||||
const auto& w = c.id;
|
||||
|
||||
for (const auto& v : c.vertices())
|
||||
for (auto &c : SCCs) {
|
||||
const auto &w = c.id;
|
||||
|
||||
for (const auto &v : c.vertices())
|
||||
A[v] = w;
|
||||
|
||||
|
||||
Out[w] = BreadthFirstTree<T>(c, w);
|
||||
In[w] = BreadthFirstTree<T>(c.reverse(), w);
|
||||
|
||||
@@ -64,20 +60,18 @@ void RodittyZwick<T>::findSCC(graph::Digraph<T> G) {
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool RodittyZwick<T>::query(const T& u, const T& v) {
|
||||
template <typename T> 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)
|
||||
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];
|
||||
template <typename T> void RodittyZwick<T>::remove(const T &u, const T &v) {
|
||||
const auto &w = A[u];
|
||||
C[w].remove(u, v);
|
||||
this->G.remove(u, v);
|
||||
|
||||
@@ -85,8 +79,9 @@ void RodittyZwick<T>::remove(const T& u, const T& v) {
|
||||
if (A[u] != A[v])
|
||||
return;
|
||||
|
||||
// If edge (u,v) is not contained in both inTree and outTree do nothing TODO:remove useless comments
|
||||
// is this not better if i utilize A matrix, since we are going traversing between components.. ? TODO
|
||||
// If edge (u,v) is not contained in both inTree and outTree do nothing
|
||||
// TODO:remove useless comments is this not better if i utilize A matrix,
|
||||
// since we are going traversing between components.. ? TODO
|
||||
if (!In[w].adjList[u].contains(v) && !Out[w].adjList[u].contains(v))
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user