Refactor: Rename adjMatrix to adjList
This commit is contained in:
@@ -16,7 +16,7 @@ class Tarjan {
|
||||
public:
|
||||
Tarjan() = default;
|
||||
|
||||
Tarjan(std::map<T, std::set<T>> adjMatrix) : adjMatrix(adjMatrix) {}
|
||||
Tarjan(std::map<T, std::set<T>> adjList) : adjList(adjList) {}
|
||||
|
||||
//
|
||||
auto execute();
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
//
|
||||
void strongConnect(const T& u);
|
||||
private:
|
||||
std::map<T, std::set<T>> adjMatrix;
|
||||
std::map<T, std::set<T>> adjList;
|
||||
std::stack<T> S;
|
||||
std::int16_t index = 0;
|
||||
std::vector<SCC<T>> SCCs;
|
||||
@@ -44,7 +44,7 @@ void Tarjan<T>::strongConnect(const T& u) {
|
||||
S.push(u);
|
||||
vmap[u].onStack = true;
|
||||
|
||||
for (const auto& w : adjMatrix[u]) {
|
||||
for (const auto& w : adjList[u]) {
|
||||
if (vmap[w].index == -1) {
|
||||
strongConnect(w);
|
||||
vmap[u].lowlink = std::min(vmap[u].lowlink, vmap[w].lowlink);
|
||||
@@ -63,7 +63,7 @@ void Tarjan<T>::strongConnect(const T& u) {
|
||||
const auto w = S.top();
|
||||
S.pop();
|
||||
vmap[w].onStack = false;
|
||||
scc[w] = adjMatrix[w];
|
||||
scc[w] = adjList[w];
|
||||
finished = (w == u);
|
||||
} while (!finished);
|
||||
|
||||
@@ -73,7 +73,7 @@ void Tarjan<T>::strongConnect(const T& u) {
|
||||
|
||||
template<typename T>
|
||||
auto Tarjan<T>::execute() {
|
||||
for (const auto& u : std::views::keys(adjMatrix)) {
|
||||
for (const auto& u : std::views::keys(adjList)) {
|
||||
if (vmap[u].index == -1)
|
||||
strongConnect(u);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user