to_BFS function

Function to rearrage nodes in BFS