Change project structure

This commit is contained in:
stefiosif
2022-06-27 22:45:26 +03:00
parent e488b309c8
commit 8d8e6ef831
5 changed files with 90 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
#ifndef DECREMENTAL_MAINTENANCE_H_ #ifndef DECREMENTAL_SCC_H_
#define DECREMENTAL_MAINTENANCE_H_ #define DECREMENTAL_SCC_H_
#include "graph/digraph.h" #include "graph/digraph.h"
#include "graph/scc.h" #include "graph/scc.h"
@@ -12,9 +12,9 @@ using namespace graph;
namespace algo { namespace algo {
template<typename T> template<typename T>
class DecrementalMaintenance : public RodittyZwick<T> { class DecrementalSCC : public RodittyZwick<T> {
public: public:
DecrementalMaintenance(Digraph<T> G) : G(G) {} DecrementalSCC(Digraph<T> G) : G(G) {}
// //
void init(); void init();
@@ -40,7 +40,7 @@ private:
}; };
template<typename T> template<typename T>
void DecrementalMaintenance<T>::init() { void DecrementalSCC<T>::init() {
auto tarjan = Tarjan<T>(G).run(); auto tarjan = Tarjan<T>(G).run();
for (auto& C : tarjan) { for (auto& C : tarjan) {
@@ -60,12 +60,12 @@ void DecrementalMaintenance<T>::init() {
} }
template<typename T> template<typename T>
bool DecrementalMaintenance<T>::query(const T& u, const T& v) { bool DecrementalSCC<T>::query(const T& u, const T& v) {
return A[u] == A[v]; return A[u] == A[v];
} }
template<typename T> template<typename T>
void DecrementalMaintenance<T>::remove(const T& u, const T& v) { void DecrementalSCC<T>::remove(const T& u, const T& v) {
// If u and v are not in the same SCC, do nothing // If u and v are not in the same SCC, do nothing
if (A[u] != A[v]) return; if (A[u] != A[v]) return;

View File

@@ -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<typename T>
class DecrementalTC : public RodittyZwick<T> {
public:
DecrementalTC(Digraph<T> G) : G(G) {}
//
void init();
//
bool query(const T& u, const T& v);
//
void remove(const T& u, const T& v);
};
template<typename T>
inline void DecrementalTC<T>::init() {
}
template<typename T>
inline bool DecrementalTC<T>::query(const T& u, const T& v) {
return false;
}
template<typename T>
inline void DecrementalTC<T>::remove(const T& u, const T& v) {
}
} // namespace algo
#endif

17
graph/dag.h Normal file
View File

@@ -0,0 +1,17 @@
#ifndef DAG_H_
#define DAG_H_
#include "digraph.h"
namespace graph {
// Directed Acyclic Graph
template<typename T>
class DAG {
public:
DAG() = default;
};
} // namespace graph
#endif

View File

@@ -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<typename T>
class TransitiveClosure {
public:
TransitiveClosure() = default;
};
} // namespace graph
#endif

View File

@@ -4,7 +4,7 @@
#include "graph/scc.h" #include "graph/scc.h"
#include "algorithm/tarjan.h" #include "algorithm/tarjan.h"
#include "algorithm/bfs.h" #include "algorithm/bfs.h"
#include "algorithm/decremental_maintenance.h" #include "algorithm/decremental_scc.h"
using namespace graph; using namespace graph;
@@ -130,7 +130,7 @@ TEST_SUITE("Algorithm") {
G.insert(6, 3); G.insert(6, 3);
G.insert(7, 2); G.insert(7, 2);
algo::DecrementalMaintenance<std::uint16_t> rz(G); algo::DecrementalSCC<std::uint16_t> rz(G);
rz.init(); rz.init();
//CHECK_EQ(rz.query(1, 2), true); //CHECK_EQ(rz.query(1, 2), true);