Dijkstra

Colors: Red: d(i) Yellow: node d(j) and arc (i,j) Green: set shortest path to source
At the end of alg shortest path from source to sink is highlighted in yellow.


Algorithm

Each node is given a distance label, d(i), which represents an upper bound on the distance of the shortest path to reach it from the source. To begin all the distance labels are set to infinity except for the source which has a distance label of 0, since it is obviously 0 away from the source. From here the algorithm works by selecting a node whose distance label is greater than the distance label of one of its predecessors plus the distance of the arc between the two and reseting it to this new, lower upper bound. That is if d(j) > d(i) + c(i,j) where c(i j) is the distance of an arc from node i to node j d(j) is set to d(i) + c(i, j). This continues until no more labels can be set. This algorithm works in O(n^2).

Dijkstra
"Simplicity is prerequisite for reliability." E.W. Dijkstra
Edsger Wybe Dijkstra was born in Rotterdam, Netherlands in 1930. A bright child Dijkstra studied Greek, Latin, French, German, English, biology, mathematics, and chemistry. Orginally drawn to the study of law Dijkstras excellence in chemistry, mathematics, and physics, lead him to theoretical physics and later programming. At this time (1950's) however programming still was not officially recognized as a profession. In the 70's, Dijkstra moved to the US and awarded the ACM Turing Award in 1972. Besides his shortest path algorithm Dijktra is also known for his solving of the dining philosphers problem through the invention of "semaphores". Dijkstra was promoter logically simple solutions in programming as made apparent by the quote above and his famous letter entitled "GO TO considered harmful"

Code
Dijkstra.java
Node.java
Edge.java
Graph.java
MainApplet.java