Dijkstra algorithm Implementation in java