From 89a2a24f50d76ca1a8d042cd676fc8848d11e7a9 Mon Sep 17 00:00:00 2001 From: stefiosif Date: Tue, 17 May 2022 21:25:47 +0300 Subject: [PATCH] Add decremental maintenance of SCCs frame --- algorithm/dmscc.h | 19 +++++++++++++++++++ graph/graph.h | 8 ++++++++ graph/scc.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 algorithm/dmscc.h create mode 100644 graph/scc.h diff --git a/algorithm/dmscc.h b/algorithm/dmscc.h new file mode 100644 index 0000000..4296a86 --- /dev/null +++ b/algorithm/dmscc.h @@ -0,0 +1,19 @@ +#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 +class DMSCC { +public: + DMSCC() = default; +}; + +}; // namespace algo + +#endif \ No newline at end of file diff --git a/graph/graph.h b/graph/graph.h index 2963e6f..7e3ecf2 100644 --- a/graph/graph.h +++ b/graph/graph.h @@ -20,6 +20,9 @@ public: // Add edge between v and u void insert(const T& v, const T& u); + // Reverse graph directions + Graph reverse(); + // Adjacency matrix representation std::set vertices; std::map> adjMatrix; @@ -37,6 +40,11 @@ void Graph::insert(const T& v, const T& u) { adjMatrix[v].insert(u); } +template +Graph Graph::reverse() { + return Graph(); +} + } // namespace graph #endif \ No newline at end of file diff --git a/graph/scc.h b/graph/scc.h new file mode 100644 index 0000000..2943c7c --- /dev/null +++ b/graph/scc.h @@ -0,0 +1,47 @@ +#ifndef SCC_H_ +#define SCC_H_ + +#include "graph/graph.h" + +namespace graph { + +template +class SCC { +public: + SCC(std::vector scc); + + // Construct shortest path + std::vector SPT(); + + // Convert SCC into a Graph + Graph convert(); +private: + std::vector scc; + // Representative - Root(SPT) of this SCC + T root; +}; + +template +SCC::SCC(std::vector component) { + scc = component; + root = scc[0]; +} + +template +std::vector SCC::SPT() { + + // BFS + + return std::vector(); +} + +template +Graph SCC::convert() { + + + return Graph(); +} + +}; // namespace graph + +#endif \ No newline at end of file