Then the following operation will construct a search tree in a "best-first" fashion:
Search(s)
d[s] = 0
pred[s] = null
PQ = {s}
while PQ ≠ {} do
u = Remove[PQ]
if success
then return u
else
for each v ∈ Expand(u) do
Add(PQ,v)
return null