Question
Does Dijkstra's algorithm work for graphs with both
negative and positive edge weights?Solution
Dijkstra's algorithm is a well-known algorithm for finding the shortest paths from a single source vertex to all other vertices in a graph. However, it assumes that all edge weights are non-negative. This is because Dijkstra's algorithm relies on the fact that once a vertex's shortest path is determined, it will not change. If there were negative weights, a shorter path might be found later, invalidating the correctness of the algorithm. For example, if a graph has a negative weight edge, Dijkstra's algorithm might incorrectly calculate the shortest path by not considering a path that includes the negative edge. This limitation is why Dijkstra’s algorithm is not suitable for graphs with negative edge weights. Instead, algorithms like Bellman-Ford are used for graphs where negative weights are present, as they can correctly handle such situations.
According to Mahatma Gandhi, which symbol represented the unity, economic independence, and equality of Indian society?
Who became the first Indian bowler to take 100 wickets in T20 Internationals?
Which village in Maharashtra is set to become India’s first ‘Smart Intelligent Village’?
How many Indian Army personnel are participating in Exercise SURYAKIRAN XIX in 2025?
What is the primary purpose of the National Legal Metrology Portal ( eMaap )?
How many pillars form the foundation of Maharashtra’s new education policy as aligned with NEP 2020?
Why did Uttar Pradesh invoke the Essential Services Maintenance Act (ESMA) for six months?
What is the estimated annual ethanol production capacity of India’s first bamboo-based bioethanol plant?
Which of the following is NOT covered under the Bima Vistaar insurance model approved by IRDAI?
What is the total balance held in Pradhan Mantri Jan Dhan Yojana (PMJDY) accounts as of October 22, 2025?