Change project structure
This commit is contained in:
@@ -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<typename T>
|
||||
class DecrementalMaintenance : public RodittyZwick<T> {
|
||||
class DecrementalSCC : public RodittyZwick<T> {
|
||||
public:
|
||||
DecrementalMaintenance(Digraph<T> G) : G(G) {}
|
||||
DecrementalSCC(Digraph<T> G) : G(G) {}
|
||||
|
||||
//
|
||||
void init();
|
||||
@@ -40,7 +40,7 @@ private:
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
void DecrementalMaintenance<T>::init() {
|
||||
void DecrementalSCC<T>::init() {
|
||||
auto tarjan = Tarjan<T>(G).run();
|
||||
|
||||
for (auto& C : tarjan) {
|
||||
@@ -60,12 +60,12 @@ void DecrementalMaintenance<T>::init() {
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
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 (A[u] != A[v]) return;
|
||||
|
||||
46
algorithm/decremental_tc.h
Normal file
46
algorithm/decremental_tc.h
Normal 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
17
graph/dag.h
Normal 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
|
||||
18
graph/transitive_closure.h
Normal file
18
graph/transitive_closure.h
Normal 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
|
||||
@@ -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<std::uint16_t> rz(G);
|
||||
algo::DecrementalSCC<std::uint16_t> rz(G);
|
||||
rz.init();
|
||||
|
||||
//CHECK_EQ(rz.query(1, 2), true);
|
||||
|
||||
Reference in New Issue
Block a user