Add method to access adjMatrix keys and add adjMatrix on seaching method

This commit is contained in:
stefiosif
2022-09-19 22:04:45 +03:00
parent 0b16ebc677
commit 40f23c5bf8

View File

@@ -4,6 +4,8 @@
#include "graph.h"
#include "algorithm/breadth_first_search.h"
#include <ranges>
namespace graph {
template<typename T>
@@ -24,6 +26,9 @@ public:
// Reverse graph directions
auto reverse();
// Return vertices
auto vertices();
};
template<typename T>
@@ -33,7 +38,7 @@ Digraph<T>::Digraph(std::map<T, std::set<T>> G) {
template<typename T>
bool Digraph<T>::contains(const T& u, const T& v) {
return algo::BreadthFirstSearch<T>().query(u, v);
return algo::BreadthFirstSearch<T>(this->adjMatrix).query(u, v);
}
template<typename T>
@@ -62,6 +67,11 @@ auto Digraph<T>::reverse() {
return revMatrix;
}
template<typename T>
auto Digraph<T>::vertices() {
return std::views::keys(this->adjMatrix);
}
} // namespace graph
#endif