BreadFirstSearch for undirected graphs