Add roditty and zwick class

This commit is contained in:
stefiosif
2022-06-12 20:33:11 +03:00
parent 4058c3f6fb
commit cc79737ecc
5 changed files with 95 additions and 24 deletions

View File

@@ -1,19 +0,0 @@
#ifndef DMSCC_H_
#define DMSCC_H_
#include "graph/graph.h"
using namespace graph;
#include "tarjan.h"
namespace algo {
// A randomized decremental algorithm for maintaining SCCs
template<typename T>
class DMSCC {
public:
DMSCC() = default;
};
}; // namespace algo
#endif

55
algorithm/roditty_zwick.h Normal file
View File

@@ -0,0 +1,55 @@
#ifndef RODITTY_ZWICK_H_
#define RODITTY_ZWICK_H_
#include "graph/digraph.h"
#include "graph/scc.h"
#include "algorithm/tarjan.h"
#include "algorithm/bfs.h"
#include <vector>
using namespace graph;
namespace algo {
// A randomized decremental algorithm for maintaining SCCs
template<typename T>
class RodittyZwick {
public:
RodittyZwick(Digraph<T> G) : G(G) {}
//
void sccDecrementalMaintenance();
//
void tcDecrementalMaintenance();
private:
Digraph<T> G;
};
template<typename T>
void RodittyZwick<T>::sccDecrementalMaintenance() {
std::map<T, T> A;
Tarjan<T> tarjan(G);
auto sccs = tarjan.run();
for (auto& scc : sccs) {
const auto& root = scc.representative();
BFS<T> bfs(scc);
auto spt = bfs.run(root);
for (const auto& vertex : scc.vertices) {
A[vertex] = root;
}
}
}
template<typename T>
void RodittyZwick<T>::tcDecrementalMaintenance() {
}
}; // namespace algo
#endif