Priority queue for Dijkstra [00O3]

  • We will expand d to keep track of not just the shortest distances to  vertices, but the current shortest known distances to other vertices as well. So d[v] will always be an upper bound on the shortest distance from s to v. We may have to update d[v] every time we add a vertex u to S with an edge (u,v).
  • We will expand the \mathit {parent} map similarly: \mathit {parent}[v] is the predecessor of v along the currently shortest known path from s.

The idea is that at each iteration we want to pick the unvisited vertex v with the smallest d[v]. We will store the unvisited vertices in some kind of data structure so that we can quickly remove the one with the smallest d[v]. We then need to be able to update d and \mathit {parent} appropriately.

So we need a data structure that allows us to:

  • Add new items with a given value
  • Remove the item with the smallest value
  • Update the value of an existing item
i.e. a priority queue.