From 4058c3f6fb96d932b9b9b89ca5873f9fce947ced Mon Sep 17 00:00:00 2001 From: stefiosif Date: Sun, 12 Jun 2022 20:32:15 +0300 Subject: [PATCH] Make bfs return a digraph since shortest-path in-out trees are directed graphs --- algorithm/bfs.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/algorithm/bfs.h b/algorithm/bfs.h index 79c0ff2..739cac3 100644 --- a/algorithm/bfs.h +++ b/algorithm/bfs.h @@ -12,16 +12,16 @@ namespace algo { template class BFS { public: - BFS(Digraph G, T root) : G(G), root(root) {} + BFS(Graph G) : G(G) {} // - std::map> run(); + Digraph run(const T& root); - // + // Initialize the lookup table that is used to + // show which vertices have been traversed std::map initExplore(); private: - Digraph G; - T root; + Graph G; }; template @@ -34,7 +34,7 @@ std::map BFS::initExplore() { } template -std::map> BFS::run() { +Digraph BFS::run(const T& root) { std::map> tree; std::map graphExplore = initExplore(); std::queue Q; @@ -54,7 +54,7 @@ std::map> BFS::run() { } } - return tree; + return Digraph(tree); } } // namespace algo