Uniform Cost Search


Cannot Find Image...

Uniform cost search is a search algorithm used to traverse, and find the shortest path in weighted trees and graphs. Uniform Cost Search or UCS begins at a root node and will continually expand nodes, taking the node with the smallest total cost from the root until it reaches the goal state. Uniform cost search doesn't care about how many steps a path has, only the total cost of the path. For this reason zero cost paths leading back to the same state are problematic for UCS because they will result in an infinite loop - staying at one node and never moving. In order to ensure that UCS is optimal and complete every path length must be larger than some small value epsilon. Uniform cost search closely resembles Dijkstra's algorithm for finding the shortest path in a weighted graph.

UCS is easily implemented by using a priority queue. All nodes on the fringe have an associated weight which represents the cost of traveling to that node. Take for example the tree in the above image. S is the start node and G is the goal node. The numbers next to the nodes represent the total cost to get to that node by traversing the tree. Nodes are removed from the priority queue in order of the shortest total length to that node. The order in which nodes are removed from the queue is known as the expansion order.

The expansion order of the above graph would be: s q d b e a r f e g.

When a node is taken from the fringe, all of the nodes that are connected to the removed node are added to the fringe.

Below is an animation illustrating how UCS explores a graph based on the weights of the edges.
Cannot Find Image...
UCS with all path costs equal to one is identical to breadth first search. Another way to think about Uniform Cost Search is that it is essentially A* search using a heuristic that is zero for every node. That way the only thing that effects what nodes are taken from the fringe is the total distance from the start to the node being considered.

Cannot Find Image...

Sources:


Artificial Intelligence A Modern Approach pages 75, 87
CS6300 - Day 02 Slides
Wikipedia - Dijkstra's algorithm
Wikipedia - Uniform-cost search