#ifndef SCC_H_ #define SCC_H_ #include "digraph.h" namespace graph { template class SCC : public Digraph { public: SCC() = default; SCC(std::map> G, T id) : Digraph(G), id(id) { normalize(); } SCC(Digraph G, T id) : id(id) { normalize(); } T id; bool operator==(const SCC& o) const; private: // For every vertex in the SCC, if there is an edge between an in-scc vertex // and an out-scc vertex erase the edge between them and the out-scc vertex void normalize(); }; template void SCC::normalize() { for (const auto& u : this->adjMatrix) { for (const auto& v : u.second) { if (!this->adjMatrix.count(v)) { this->adjMatrix[u.first].erase(v); this->adjMatrix.erase(v); } } } } template bool SCC::operator==(const SCC& o) const{ return id == o.id; } }; // namespace graph #endif