Fix the edges that are output during BFS