Uniform-Cost Search is a variant of Dijikstra’s algorithm. Here, instead of inserting all vertices into a priority queue, we insert only source, then one by one insert when needed. In every step, we check if the item is already in priority queue (using visited array). If yes, we perform decrease key, else we insert it.
This variant of Dijsktra is useful for infinite graphs and those graph which are too large to represent in the memory. Uniform-Cost Search is mainly used in Artificial Intelligence.
Input : Output : Minimum cost from S to G is =3
Uniform-Cost Search is similar to Dijikstra’s algorithm . In this algorithm from the starting state we will visit the adjacent states and will choose the least costly state then we will choose the next least costly state from the all un-visited and adjacent states of the visited states, in this way we will try to reach the goal state (note we wont continue the path through a goal state ), even if we reach the goal state we will continue searching for other possible paths( if there are multiple goals) . We will keep a priority queue which will give the least costliest next state from all the adjacent states of visited states .
Minimum cost from 0 to 6 is = 3
Complexity: O( m ^ (1+floor(l/e)))
m is the maximum number of neighbor a node has
l is the length of the shortest path to the goal state
e is the least cost of an edge
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Dijkstra's shortest path algorithm | Greedy Algo-7
- Printing Paths in Dijkstra's Shortest Path Algorithm
- Dijkstra’s shortest path algorithm using set in STL
- Dijkstra's Shortest Path Algorithm using priority_queue of STL
- Dial's Algorithm (Optimized Dijkstra for small range weights)
- Java Program for Dijkstra's Algorithm with Path Printing
- Comparison of Dijkstra’s and Floyd–Warshall algorithms
- C / C++ Program for Dijkstra's shortest path algorithm | Greedy Algo-7
- Dijkstra's shortest path with minimum edges
- Dijkstra's shortest path algorithm in Java using PriorityQueue
- Java Program for Dijkstra's shortest path algorithm | Greedy Algo-7
- Python Program for Dijkstra's shortest path algorithm | Greedy Algo-7
- C# Program for Dijkstra's shortest path algorithm | Greedy Algo-7
- Widest Path Problem | Practical application of Dijkstra's Algorithm
- Shortest path in a directed graph by Dijkstra’s algorithm
- Minimum Cost using Dijkstra by reducing cost of an Edge
- Applications of Dijkstra's shortest path algorithm
- What are the differences between Bellman Ford's and Dijkstra's algorithms?
- Dijkstra’s Algorithm for Adjacency List Representation | Greedy Algo-8
- Number of Triangles in Directed and Undirected Graphs
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.