Search(s)
d[s] = 0
pred[s] = null
PQ = {s}
Open = {s}
Closed = {}
while PQ ≠ {} do
u = Remove[PQ]
Remove(Open,u)
if success
then return u
else
for each v ∈ Expand(u) do
if there is an x such that x = v and x ∈ Open // Scenario 1
if d[v] < d[x]
then d[x] = d[v]
pred[x] = pred[v]
Promote(PQ,x)
else if there is an x such that x = v and x ∈ Closed // Scenario 2
if d[v] < d[x]
then d[x] = d[v]
pred[x] = pred[v]
Add(PQ,x)
Add(Open,x)
Remove(Closed,x)
else
Add(PQ,v)
Add(Open,v)
Add(Closed,u)
return null