Is Dijkstra's algorithm the most suitable for finding the shortest distance between two nodes, where all of the paths in the graph are equal to 1.
If not what is a more time efficient way of implementing this?
Is Dijkstra's algorithm the most suitable for finding the shortest distance between two nodes, where all of the paths in the graph are equal to 1.
If not what is a more time efficient way of implementing this?
When your graph has edge weights that are the same positive constant, then your graph is actually unweighted. Dijkstra's algorithm is intended for weighted graphs. If you apply it to unweighted graphs, then the priority queue used in that algorithm can be replaced by a FIFO queue. This turns the algorithm into a standard breadth-first search.
This is also what is stated in the Wikipedia entry on Dijkstra's algorithm:
Breadth-first search can be viewed as a special-case of Dijkstra's algorithm on unweighted graphs, where the priority queue degenerates into a FIFO queue.
a* can be faster. But this question is mostly a dupe of others.