Added functionality for bfs and Dijkstra