From 8d8e6ef831b098fc7fa0850f24c1e05383c3a02e Mon Sep 17 00:00:00 2001 From: stefiosif Date: Mon, 27 Jun 2022 22:45:26 +0300 Subject: [PATCH] Change project structure --- ...mental_maintenance.h => decremental_scc.h} | 14 +++--- algorithm/decremental_tc.h | 46 +++++++++++++++++++ graph/dag.h | 17 +++++++ graph/transitive_closure.h | 18 ++++++++ test/algorithm_test.cc | 4 +- 5 files changed, 90 insertions(+), 9 deletions(-) rename algorithm/{decremental_maintenance.h => decremental_scc.h} (83%) create mode 100644 algorithm/decremental_tc.h create mode 100644 graph/dag.h create mode 100644 graph/transitive_closure.h diff --git a/algorithm/decremental_maintenance.h b/algorithm/decremental_scc.h similarity index 83% rename from algorithm/decremental_maintenance.h rename to algorithm/decremental_scc.h index a20ef2d..6c018dc 100644 --- a/algorithm/decremental_maintenance.h +++ b/algorithm/decremental_scc.h @@ -1,5 +1,5 @@ -#ifndef DECREMENTAL_MAINTENANCE_H_ -#define DECREMENTAL_MAINTENANCE_H_ +#ifndef DECREMENTAL_SCC_H_ +#define DECREMENTAL_SCC_H_ #include "graph/digraph.h" #include "graph/scc.h" @@ -12,9 +12,9 @@ using namespace graph; namespace algo { template -class DecrementalMaintenance : public RodittyZwick { +class DecrementalSCC : public RodittyZwick { public: - DecrementalMaintenance(Digraph G) : G(G) {} + DecrementalSCC(Digraph G) : G(G) {} // void init(); @@ -40,7 +40,7 @@ private: }; template -void DecrementalMaintenance::init() { +void DecrementalSCC::init() { auto tarjan = Tarjan(G).run(); for (auto& C : tarjan) { @@ -60,12 +60,12 @@ void DecrementalMaintenance::init() { } template -bool DecrementalMaintenance::query(const T& u, const T& v) { +bool DecrementalSCC::query(const T& u, const T& v) { return A[u] == A[v]; } template -void DecrementalMaintenance::remove(const T& u, const T& v) { +void DecrementalSCC::remove(const T& u, const T& v) { // If u and v are not in the same SCC, do nothing if (A[u] != A[v]) return; diff --git a/algorithm/decremental_tc.h b/algorithm/decremental_tc.h new file mode 100644 index 0000000..b8c4298 --- /dev/null +++ b/algorithm/decremental_tc.h @@ -0,0 +1,46 @@ +#ifndef DECREMENTAL_TC_H_ +#define DECREMENTAL_TC_H_ + +#include "graph/digraph.h" +#include "graph/scc.h" +#include "algorithm/tarjan.h" +#include "algorithm/bfs.h" +#include "algorithm/roditty_zwick.h" + +namespace algo { + +template +class DecrementalTC : public RodittyZwick { +public: + DecrementalTC(Digraph G) : G(G) {} + + // + void init(); + + // + bool query(const T& u, const T& v); + + // + void remove(const T& u, const T& v); +}; + + +template +inline void DecrementalTC::init() { + +} + +template +inline bool DecrementalTC::query(const T& u, const T& v) { + + return false; +} + +template +inline void DecrementalTC::remove(const T& u, const T& v) { + +} + +} // namespace algo + +#endif \ No newline at end of file diff --git a/graph/dag.h b/graph/dag.h new file mode 100644 index 0000000..4883425 --- /dev/null +++ b/graph/dag.h @@ -0,0 +1,17 @@ +#ifndef DAG_H_ +#define DAG_H_ + +#include "digraph.h" + +namespace graph { + +// Directed Acyclic Graph +template +class DAG { +public: + DAG() = default; +}; + +} // namespace graph + +#endif \ No newline at end of file diff --git a/graph/transitive_closure.h b/graph/transitive_closure.h new file mode 100644 index 0000000..c363f89 --- /dev/null +++ b/graph/transitive_closure.h @@ -0,0 +1,18 @@ +#ifndef TRANSITIVE_CLOSURE_H_ +#define TRANSITIVE_CLOSURE_H_ + +#include "digraph.h" + +namespace graph { + +// Transitive closure matrix class to answer reachability queries +template +class TransitiveClosure { +public: + TransitiveClosure() = default; +}; + +} // namespace graph + + +#endif \ No newline at end of file diff --git a/test/algorithm_test.cc b/test/algorithm_test.cc index ab465df..2f64fec 100644 --- a/test/algorithm_test.cc +++ b/test/algorithm_test.cc @@ -4,7 +4,7 @@ #include "graph/scc.h" #include "algorithm/tarjan.h" #include "algorithm/bfs.h" -#include "algorithm/decremental_maintenance.h" +#include "algorithm/decremental_scc.h" using namespace graph; @@ -130,7 +130,7 @@ TEST_SUITE("Algorithm") { G.insert(6, 3); G.insert(7, 2); - algo::DecrementalMaintenance rz(G); + algo::DecrementalSCC rz(G); rz.init(); //CHECK_EQ(rz.query(1, 2), true);