Refactor: Rename adjMatrix to adjList

This commit is contained in:
stefiosif
2022-10-12 16:57:48 +03:00
parent 8b6d341d18
commit c525aeaa43
14 changed files with 56 additions and 56 deletions

View File

@@ -28,23 +28,23 @@ public:
template<typename T>
Digraph<T>::Digraph(std::map<T, std::set<T>> G) {
this->adjMatrix = G;
this->adjList = G;
}
template<typename T>
bool Digraph<T>::contains(const T& u, const T& v) {
return algo::BreadthFirstSearch<T>(this->adjMatrix).query(u, v);
return algo::BreadthFirstSearch<T>(this->adjList).query(u, v);
}
template<typename T>
void Digraph<T>::insert(const T& u, const T& v) {
this->adjMatrix[u].insert(v);
this->adjMatrix[v];
this->adjList[u].insert(v);
this->adjList[v];
}
template<typename T>
void Digraph<T>::remove(const T& u, const T& v) {
this->adjMatrix[u].erase(v);
this->adjList[u].erase(v);
}
template<typename T>
@@ -52,7 +52,7 @@ auto Digraph<T>::reverse() {
std::map<T, std::set<T>> revMatrix;
for (const auto& u : this->vertices()) {
for (const auto& v : this->adjMatrix[u]) {
for (const auto& v : this->adjList[u]) {
revMatrix[v].insert(u);
}
}