algorithm - Will adding a single edge to a given graph create a new shortest path? -


assume have directed graph start node , end node c, , know shortest path c in graph of length n , uses nodes a, b0,b1, ..., bn-2, c.

i want know whether adding given new edge graph create new shortest path c of length < n. of course, use dijkstra's algorithm check shortest path in new graph, question whether information have shortest path in graph without new edge can somehow used solve problem more efficiently?

you add new edge (u,v), need check if triangular inequality holds:

d(v) < d(u) + w(u,v) 

if does, there no new shortest path.

otherwise, have new shortest path source (a) v, invalidates shortest paths weight greater new d(v).


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -