Make class Graph abstract and make derived classes Digraph and SCC

This commit is contained in:
stefiosif
2022-06-12 00:49:42 +03:00
parent b5b031db7f
commit 72741a6a5b
7 changed files with 113 additions and 113 deletions

View File

@@ -1,45 +1,27 @@
#ifndef SCC_H_
#define SCC_H_
#include "graph/graph.h"
#include "graph.h"
#include <ranges>
namespace graph {
template<typename T>
class SCC {
class SCC : public Graph<T> {
public:
SCC(std::vector<T> scc);
SCC(std::map<T, std::set<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>();
SCC<T>::SCC(std::map<T, std::set<T>> scc) {
Graph<T>::adjMatrix = scc;
auto kv = std::views::keys(Graph<T>::adjMatrix);
Graph<T>::vertices = std::set<T>{ kv.begin(), kv.end() };
root = scc.begin()->first;
}
}; // namespace graph