graph - Dijsktra's Algorithm to accept a single negative edge -


so i've been working dijkstra's algorithm , directed graphs lot lately. however, can't seem figure out , it's starting bother me.

show how modify dijkstra’s algorithm solve single source shortest path problem if there 1 negative weight edge no negative weight cycles.

so far initial thought has been somehow split graphs , perform algorithm separately, that's i've thought of.

i've found explanation i'm looking for, can't seem follow his explanation

well answered! i'd point out if number of negative edges limited, there dijkstra-based algorithms might better job. example, if there 1 negative edge u v, run dijkstra on s , on v, , take minimum each vertex between d[s] , d[s]+w(u, v)+d[v], giving complexity of running dijkstra twice

remove negative edge (u, v), run dijkstra twice: once starting @ s (d1) , once starting @ v (d2)

the shortest path between s , t is: min(d1[t], d1[u]+d2[t]+w(u, v)).


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -