Procedure UniformCostSearch
Procedure UniformCostSearch
if frontier is empty
return failure
node := frontier.pop
if node is goal
return solution
explored.add(node)
for each of node's neighbors n
if n is not in explored
if n is not in frontier
frontier.add(n)
else if n is in frontier with higher cost
replace existing node with n