Make SCC inherit parent constructor to avoid duplicate code

This commit is contained in:
stefiosif
2022-07-10 13:23:27 +03:00
parent 6b1edfa164
commit 4a9cbe19f9

View File

@@ -1,18 +1,19 @@
#ifndef SCC_H_
#define SCC_H_
#include "graph.h"
#include "digraph.h"
#include <ranges>
namespace graph {
template<typename T>
class SCC : public Graph<T> {
class SCC : public Digraph<T> {
public:
SCC() = default;
SCC(std::map<T, std::set<T>> scc);
SCC(std::map<T, std::set<T>> scc)
: Digraph<T>::Digraph(scc) { proxy = scc.begin()->first; }
//
T representative() { return proxy; };
@@ -23,14 +24,6 @@ private:
};
template<typename 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() };
proxy = scc.begin()->first;
}
}; // namespace graph
#endif