# Is Dijkstra's algorithm just BFS with a priority queue?

According to this page, Dijkstra's algorithm is just BFS with a priority queue. Is it really that simple? I think not.

-

## migrated from cstheory.stackexchange.comFeb 24 '13 at 8:51

This question came from our site for theoretical computer scientists and researchers in related fields.

Why do you think that? –  Raphael Feb 24 '13 at 16:18
@Raphael Because it seems too simple, and it is: I studied it again and I see now it doesn't keep track of the distance between nodes, so it's really a BFS, not Dijkstra. –  Barry Fruitman Feb 24 '13 at 18:21
Well, Dijkstra does change the values the queue is "sorted" with (often called "relaxation"); if you forbid that, it's not the same, true. –  Raphael Feb 24 '13 at 23:15

Dijkstra's algorithm relies on the property that the shortest path from $s$ to $t$ is also the shortest path to any of the vertices along the path. This is exactly what BFS does.