Dijkstra's algorithm for Single Source Shortest Path 1) greedy algorithm 2) uses edge "relaxation" 3) works in a way similar to Prim's greedy MST algorithm 4) O(|V|^2) can be expressed formally as follows: GIVEN: graph - arbitrary connected graph sourceVertex - is the initial beginning vertex V - is the set of all vertices in the graph theGraph (given) n - number of vertices in theGraph (given) cost - set of edges in theGraph (given) WORKING ON: seen - set of all "seen" vertices with permanent labels; it is the "chosen set" (what we are building) unseen - set of all "unseen" vertices; those yet to be processed dist - set of "distances" to sourceVertex (priority queue) (what we are perfecting) Dijkstra Algorithm (graph theGraph, vertex sourceVertex) { seen = {sourceVertex} // this is the set of chosen vertices (vertices that have been used) unseen = V - {sourceVertex} dist[sourceVertex] = 0 // distance from source to source is 0 (in blue) // (dist holds distances from source as we work on them) for i = 1 to n // use infinity for those where no edge exists from source dist[i] = cost[sourceVertex, i] // dist should be a priority queue for i = 2 to n // until all vertices have been chosen (the first vertex, the source has been done) choose vertex w in unseen where D[w] is min // should be a priority queue seen = seen + {w} unseen = unseen - {w} for each vertex v in unseen // update if this distance is better dist[v] = min(dist[v], dist[w] + cost[w, v]) // relax the effected unchosen nodes in priority queue }