Java computer science question

Java computer science question




I'm doing a program that finds the shortest distance between two cities given different routes (through other cities: connections). I have a hashmap called shortestknowndistance. All I want to do is set d to the distance to the target city. What do I do?





Map<String, TreeSet<DistanceTo>> shortestKnownDistance = new HashMap<String, TreeSet<DistanceTo>>();



Scanner in = new Scanner(System.in);

System.out.println("What is the starting city?");

String from = in.next();

System.out.println("What is the finishing city?");

String target = in.next();

DistanceTo startingPoint = new DistanceTo(from, 0);

PriorityQueue<DistanceTo> myQueue = new PriorityQueue<DistanceTo>();

myQueue.add(startingPoint);

while (myQueue.size() != 0) {

myQueue.remove();

while (!shortestKnownDistance.containsKey(targ... {

//TreeSet<DistanceTo> d = ??????????

shortestKnownDistance.put(target, d);





No Answers Posted Yet.