concept Dijkstra in category algorithms

This is an excerpt from Manning's book Algorithms and Data Structures in Action MEAP V14.
That elementToIndex[elem] by default returns -1 if elem is not stored in the heap;
Figure 14.15 The shortest path to destination, and shortest distances, to all the vertices, computed using BFS on the graph in figure 14.10. The shortest path is shown with dashed arrows, while distances are shown next to each vertex.
![]()
#1 Method dijkstra takes a graph, a starting point vertex, and a predicate (isGoal) that takes a vertex and returns true if the goal of the search is reached. Method dijkstra returns a pair with the goal vertex (if reached), and a dictionary encoding the shortest paths.

This is an excerpt from Manning's book Grokking Algorithms: An illustrated guide for programmers and other curious people.
The second path costs him $2 less, so he should take that path, right? Well, guess what? If you run Dijkstra’s algorithm on this graph, Rama will take the wrong path. He’ll take the longer path. You can’t use Dijkstra’s algorithm if you have negative-weight edges. Negative-weight edges break the algorithm. Let’s see what happens when you run Dijkstra’s algorithm on this. First, make the table of costs.