Graph Utils: extended bfs algo