Education
 

Uniform cost search

From Mathematics

Uniform cost search is a tree search algorithm related to breadth-first search. Whereas breadth-first search determines a path to the goal state that has the least number of edges, uniform cost search determines a path to the goal state that has the lowest weight.

[edit] Algorithm

Let math be a tree with weighted edges and let math be the weight of path math in math. For convenience, let math be the root of the tree and math denote the end vertex of a path math in math. [1]. With that said, let math, the set of known paths starting with math, be math. It should be noted that the weight of math is zero.

  1. If there exists math in math such that math minimizes math and math is a goal state of math, i.e., a leaf, stop. math is the path of minimal cost to the goal.
  2. Otherwise, identify math in math where math minimizes math and expand math. In other words, add to math all paths formed by adding one of the child vertices of math (if any) to math. Remove math from math; it is considered 'visited', and failure to remove it may result in non-termination of the search.
  3. Repeat first step.

[edit] Additional Details

It's worth observing that uniform cost search assumes that no edges have negative weight. If any edges have negative weight, then it is possible that a path math begins with a vertex whose edge to its parent has a high positive weight, which will exclude it from consideration by the search. This action might be faulty, though, because the total weight of math might be minimal overall, due to negative weights further on in the path. When there are negative weights in the search tree, more expensive algorithms such as the Floyd-Warshall algorithm must be used.

[edit] Notes

  1. This mapping might have been named math, but the author could not pass up the opportunity to use something that sounds like 'T.P.'.