The Dijkstra's algorithm is never used for a graph with a negative weight. The following graph has negative weight but when the Dijkstra's single source shortest path algorithm run from vertex a, it computes the correct shortest path distance to all the vertices.
I am not getting a shortest path, why does the Dijkstra's algorithm working for the first graph and not the other one, or did I make any mistake? Could anyone make me understand it? Run Dijkstra’s algorithm on the graph below considering D as the source vertex, it would make this easier to understand if you also describe the status of the distance array at each iteration.