void evaluate_bfs() { Maze maze(9, 9); maze.buildMaze(); BFS bfs; Plot *begin(maze.getPlot(0, 0)); Plot *goal(maze.getPlot(8, 8)); std::cout << "BFS" << std::endl << "begin: " << begin << std::endl; bool res = begin == goal; std::chrono::time_point<std::chrono::system_clock> start, end; start = std::chrono::system_clock::now(); auto node = bfs.search(maze.maze, *begin, *goal, maze.getMaxPlots()); end = std::chrono::system_clock::now(); int elapsed_seconds = std::chrono::duration_cast<std::chrono::nanoseconds> (end-start).count(); std::time_t end_time = std::chrono::system_clock::to_time_t(end); std::cout << "path.length: " << node->x << "=> (" << node->node->x << ", " << node->node->y << ")" << std::endl; std::cout << "finished computation at " << std::ctime(&end_time) << "elapsed time: " << elapsed_seconds << "s\n"; }
void main() { std::cout << "==== ALGORITHM REVIEW ====" << std::endl; //create a small tree Node<int> Root; Root.Data = 1; Root.ID = "root node"; Node<int> LeftRoot; LeftRoot.Data = 2; LeftRoot.Left = nullptr; LeftRoot.Right = nullptr; LeftRoot.ID = "roots left child"; Node<int> RightRoot; RightRoot.Data = 3; RightRoot.ID = "roots right child"; Root.Left = &LeftRoot; Root.Right = &RightRoot; Node<int> RightLeft; RightLeft.Data = 4; RightLeft.Left = nullptr; RightLeft.Right = nullptr; RightLeft.ID = "the left child of roots right child"; Node<int> RightRight; RightRight.Data = 5; RightRight.Left = nullptr; RightRight.Right = nullptr; RightRight.ID = "the right child of roots right child"; RightRoot.Left = &RightLeft; RightRoot.Right = &RightRight; BFS<int> bfs; std::vector<Node<int>> start; start.push_back(Root); std::cout << bfs.search(start, 2) << std::endl; std::getchar(); }