Changed the implementation of BFS, DFS, A* and A*-NK