Simple Dijkstra calculator in Java