Removed distance of edges

Hi all,

For all edges e=(source, target) in a graph, I want to know the shortest distance of the two nodes if the edge connecting them was removed. Is this the fastest way to do it?

dist_remove = []
for e in list(g.edges()):
    g.remove_edge((e.source(), e.target()))
    dist_remove.append(gt.shortest_distance(g, source=e.source(), target=e.target()))
    g.add_edge(source=e.source(), target=e.target())

You might want to use filtering instead, which would even allow you to run the loop in parallel.