Yes Dijkstra’s always gives shortest path when the edge costs are all positive. However, it can fail when there are negative edge costs.
Is Dijkstra always optimal?
In addition, Best First Search is not optimal [not guaranteed to find the shortest path], and also A*, if you do not use an admissible heuristic function, while Dijkstra’s algorithm is always optimal, since it does not relay on any heuristic.
Does Dijkstra guarantee?
Dijkstra’s Algorithm is guaranteed to find a shortest path from the starting point to the goal, as long as none of the edges have a negative cost. … Instead of selecting the vertex closest to the starting point, it selects the vertex closest to the goal. Greedy Best-First-Search is not guaranteed to find a shortest path.