- BFS(G, start, end)
- done ← false
- Set all v.found to false.
- start.found ← true
- start.parent ← NULL
- Q.enqueue(start)
- while not done and not Q.isEmpty()
- n ← Q.Dequeue()
- if end = n
- done ← done
- for v in n.adjacent()
- if not v.found
- v.parent ← n
- v.found ← true
- Q.enqueue(v)
Dijkstras(G, start, end)
- done ← false
- Set all v.found to false
- Set all v.dist to ∞
- start.found ← true
- start.dist ← 0
- start.parent ← NULL
- Q.enqueue(all v) // note this is a heap
- while not Q.empty and not done
- n ← Q.dequeue // get item with lowest cost.
- if n = end
- done ← true
- for each v in n.adj
- if n.dist + dist(n,v) < v.dist and not v.done
- v.dist ← n.dist + dist(n,v)
- v.parent ← n
A*(G, start, end);ApproxDist(v, end)
- done ← false
- Set all v.found to false
- Set all v.dist to ∞
- start.found ← true
- start.dist ← 0
- start.approx ← 0
- start.parent ← NULL
- Q.enqueue(start) // note this is a heap
- while not Q.empty and not done
- n ← Q.dequeue // get item with lowest approximated.
- if n = end
- done ← true
- for each v in n.adj
- if n.dist + dist(n,v) < v.dist and not v.done
- v.dist = n.dist + dist(n,v);
- v.approx ← v.dist + ApproxDist(v, end);
- v.parent ← n
- Q.enqueue(v)
- Return an approximation of the distance from the v to the end.