why dijkstras algo is not working on -ve nodes
Dijktras algo doubt
Hey @deepakjumani09
Dijkstra relies on one “simple” fact: if all weights are non-negative, adding an edge can never make a path shorter. That’s why picking the shortest candidate edge (local optimality) always ends up being correct (global optimality).
If that is not the case, the “frontier” of candidate edges does not send the right signals; a cheap edge might lure you down a path with positive weights while an expensive one hides a path with negative weights.
For details, I recommend you check out a correctness proof and try to do it with negative weights; observe where it breaks.
I hope your doubt is cleared. if yes dont forget to mark it resolved .
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.