Add single vertex contains method and replace vertices field with adjMatrix' keys
This commit is contained in:
@@ -27,8 +27,8 @@ private:
|
||||
template<typename T>
|
||||
std::map<T, bool> BreadthFirstSearch<T>::initExplore() {
|
||||
std::map<T, bool> graphExplore;
|
||||
for (const auto& v : G.vertices) {
|
||||
graphExplore[v] = false;
|
||||
for (const auto& v : G.adjMatrix) {
|
||||
graphExplore[v.first] = false;
|
||||
}
|
||||
return graphExplore;
|
||||
}
|
||||
|
||||
@@ -49,8 +49,8 @@ void DecrementalSCC<T>::findSCC() {
|
||||
for (auto& C : SCCs) {
|
||||
const auto& w = C.representative();
|
||||
|
||||
for (const auto& v : C.vertices)
|
||||
A[v] = w;
|
||||
for (const auto& v : C.adjMatrix)
|
||||
A[v.first] = w;
|
||||
|
||||
outTree[w] =
|
||||
BreadthFirstTree<T>(BreadthFirstSearch<T>(C).execute(w));
|
||||
|
||||
@@ -66,9 +66,9 @@ void Tarjan<T>::strongConnect(const T& v) {
|
||||
|
||||
template<typename T>
|
||||
std::vector<SCC<T>> Tarjan<T>::execute() {
|
||||
for (const auto& v : G.vertices) {
|
||||
if (p[v].index == -1) {
|
||||
strongConnect(v);
|
||||
for (auto& v : G.adjMatrix) {
|
||||
if (p[v.first].index == -1) {
|
||||
strongConnect(v.first);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user