add distance_matrix, fix BFS