Finds shortest path in a given graph using BFS and other algos