I was reading about Graph algorithms and I came across these two algorithms.
I searched a lot about this but didn\'t get any satisfactory answer!
I have a do
With SPFA algorithm, you can get shortest path with normal queue in weighted edge graph.
It is variant of bellman-ford algorithm, and it can also handle negative weights.
But on the down side, it has worse time complexity over Dijkstra's
Breadth-first search is just Dijkstra's algorithm with all edge weights equal to 1.
Dijkstra's algorithm is conceptually breadth-first search that respects edge costs.
The process for exploring the graph is structurally the same in both cases.
Blockquote while using BFS for finding shortest path in a graph what we do is We discover all the connected vertices, add them in the queue and also maintain the distance from source to that vertex. Now if we find a path from source to that vertex with still less distance then we update it!
We do not maintain a distance in BFS. It is for discovery of nodes. So we put them in a general queue and pop them. unlike in Dijikstra where we put accumulative weight of node (after relaxation) in a priority queue and pop the min distance.
So BFS would work like dijikstra in equal weight graph because.
complexity varies because of the use of simple queue and priority queue.