Implementation of Dijkstra's algorithm in Java