replace parent_map in BFS with a persistent typed array (optimization)