function GBFS ( G , s, h, goal ):
PQ.push( h(s,goal), s, [] )
while PQ is not empty:
c, v, path = PQ.pop()
if v not visited:
mark v as visited
path.append(v)
if v == goal:
return path
for all neighbors w of v:
if w not visited:
PQ.push( h(w,goal), w, path )
function ASTAR ( G, s, goal ):
PQ.push( H(s, goal), 0, s, [] )
while PQ is not empty:
h, c, v, path = PQ.pop()
if v not visited:
mark v as visited
path.append(v)
if v == goal:
return path
for all neighbors w of v:
g = c + WT(v, w)
PQ.push( g + H(w, goal), g, w, path )