map_bfs function

Apply a function to nodes in the order of a breath first search