Uniform-cost Search - Pseudocode

Pseudocode

procedure UniformCostSearch(Graph, root, goal)

node := root, cost = 0
frontier := priority queue containing node only
explored := empty set
do
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

Read more about this topic:  Uniform-cost Search