function UCS ( G , s, goal ):
PQ.push( 0, 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( c + WT(v, w), w, path )