Files
reachability-algorithms/graph/scc.h
2022-08-08 22:18:52 +03:00

35 lines
612 B
C++

#ifndef SCC_H_
#define SCC_H_
#include "digraph.h"
#include <ranges>
namespace graph {
template<typename T>
class SCC : public Digraph<T> {
public:
SCC() = default;
SCC(std::map<T, std::set<T>> scc)
: Digraph<T>::Digraph(scc) { proxy = scc.begin()->first; }
//
T representative() { return proxy; };
bool operator==(const SCC& o) const;
private:
// Each SCC has a representative vertex that helps
// answer strong connectivity queries in O(1) time
T proxy;
};
template<typename T>
bool SCC<T>::operator==(const SCC& o) const{
return proxy == o.proxy;
}
}; // namespace graph
#endif