Use clang-format
This commit is contained in:
@@ -3,24 +3,25 @@
|
||||
|
||||
#include "graph/scc.h"
|
||||
|
||||
#include <ranges>
|
||||
#include <stack>
|
||||
#include <vector>
|
||||
#include <ranges>
|
||||
|
||||
namespace algo {
|
||||
|
||||
template<typename T>
|
||||
class Tarjan {
|
||||
template <typename T> class Tarjan {
|
||||
public:
|
||||
Tarjan() = default;
|
||||
|
||||
explicit Tarjan(std::unordered_map<T, std::unordered_set<T>> adjList) : adjList(adjList) {}
|
||||
explicit Tarjan(std::unordered_map<T, std::unordered_set<T>> adjList)
|
||||
: adjList(adjList) {}
|
||||
|
||||
//
|
||||
auto execute();
|
||||
|
||||
|
||||
//
|
||||
void strongConnect(const T& u);
|
||||
void strongConnect(const T &u);
|
||||
|
||||
private:
|
||||
std::unordered_map<T, std::unordered_set<T>> adjList;
|
||||
std::stack<T> S;
|
||||
@@ -36,13 +37,12 @@ private:
|
||||
std::unordered_map<T, Vertex> V;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
void Tarjan<T>::strongConnect(const T& u) {
|
||||
template <typename T> void Tarjan<T>::strongConnect(const T &u) {
|
||||
V[u].index = V[u].lowlink = index++;
|
||||
S.push(u);
|
||||
V[u].onStack = true;
|
||||
|
||||
for (const auto& w : adjList[u]) {
|
||||
for (const auto &w : adjList[u]) {
|
||||
if (V[w].index == -1) {
|
||||
strongConnect(w);
|
||||
V[u].lowlink = std::min(V[u].lowlink, V[w].lowlink);
|
||||
@@ -64,14 +64,13 @@ void Tarjan<T>::strongConnect(const T& u) {
|
||||
scc[w] = adjList[w];
|
||||
finished = (w == u);
|
||||
} while (!finished);
|
||||
|
||||
SCCs.push_back({ scc, static_cast<T>(cid) });
|
||||
|
||||
SCCs.push_back({scc, static_cast<T>(cid)});
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto Tarjan<T>::execute() {
|
||||
for (const auto& u : std::views::keys(adjList)) {
|
||||
template <typename T> auto Tarjan<T>::execute() {
|
||||
for (const auto &u : std::views::keys(adjList)) {
|
||||
if (V[u].index == -1)
|
||||
strongConnect(u);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user