Add decremental maintenance of SCCs frame
This commit is contained in:
19
algorithm/dmscc.h
Normal file
19
algorithm/dmscc.h
Normal file
@@ -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<typename T>
|
||||||
|
class DMSCC {
|
||||||
|
public:
|
||||||
|
DMSCC() = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
}; // namespace algo
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -20,6 +20,9 @@ public:
|
|||||||
// Add edge between v and u
|
// Add edge between v and u
|
||||||
void insert(const T& v, const T& u);
|
void insert(const T& v, const T& u);
|
||||||
|
|
||||||
|
// Reverse graph directions
|
||||||
|
Graph<T> reverse();
|
||||||
|
|
||||||
// Adjacency matrix representation
|
// Adjacency matrix representation
|
||||||
std::set<T> vertices;
|
std::set<T> vertices;
|
||||||
std::map<T, std::set<T>> adjMatrix;
|
std::map<T, std::set<T>> adjMatrix;
|
||||||
@@ -37,6 +40,11 @@ void Graph<T>::insert(const T& v, const T& u) {
|
|||||||
adjMatrix[v].insert(u);
|
adjMatrix[v].insert(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
Graph<T> Graph<T>::reverse() {
|
||||||
|
return Graph<T>();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace graph
|
} // namespace graph
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
47
graph/scc.h
Normal file
47
graph/scc.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
#ifndef SCC_H_
|
||||||
|
#define SCC_H_
|
||||||
|
|
||||||
|
#include "graph/graph.h"
|
||||||
|
|
||||||
|
namespace graph {
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
class SCC {
|
||||||
|
public:
|
||||||
|
SCC(std::vector<T> scc);
|
||||||
|
|
||||||
|
// Construct shortest path
|
||||||
|
std::vector<T> SPT();
|
||||||
|
|
||||||
|
// Convert SCC into a Graph
|
||||||
|
Graph<T> convert();
|
||||||
|
private:
|
||||||
|
std::vector<T> scc;
|
||||||
|
// Representative - Root(SPT) of this SCC
|
||||||
|
T root;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
SCC<T>::SCC(std::vector<T> component) {
|
||||||
|
scc = component;
|
||||||
|
root = scc[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
std::vector<T> SCC<T>::SPT() {
|
||||||
|
|
||||||
|
// BFS
|
||||||
|
|
||||||
|
return std::vector<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
Graph<T> SCC<T>::convert() {
|
||||||
|
|
||||||
|
|
||||||
|
return Graph<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
}; // namespace graph
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user