Shortest Path Problem In Java