Added the bi-bfs, yet not sure whether it is optimal.