Given an undirected graph G with edge weights, a set of candidate edges (length |V| + |E|), and vertices A and B, find the edge that decreases the shortest path from A to B by the most.
For example:
The candidate edges are the dotted lines. The shortest path from A to B is A -> C -> D -> G -> B (cost 7). But with the edge (D, B), the shortest path is A -> C -> D -> B (cost 6), so the algorithm should return (D, B).
I came up with a brute force solution O((|V| + |E|)^2 log |V|):
but is there anything better?
One approach is:
The smaller of w+A[x]+B[y] and w+A[y]+B[x] gives the shortest path between A and B when the candidate edge is used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With