Implemented BFS to compute optimum path