Created
April 2, 2010 20:38
-
-
Save evantravers/353682 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Vector<Integer> dd() { | |
Vector<Integer> output = new Vector<Integer>(); | |
// create a list of the answers | |
ArrayList<Integer> todo = new ArrayList<Integer>(); | |
for (int i=0;i<answers.length ;i++ ) { | |
todo.add(answers[i]); | |
} | |
// call dijkstra on the first answer, looking for only the remaining answers | |
int currentValue=1; | |
while (todo.size()>0) { | |
Vector<Double> results = new Vector<Double>(); | |
results = d(currentValue); | |
// System.out.println(results); | |
// make a queue of just the results we want | |
PriorityQueue<Node> valuesFound = new PriorityQueue<Node>(); | |
for (int i=0;i<todo.size();i++) { | |
// load all the values we are looking for into the queue to be sorted | |
valuesFound.add(new Node(todo.get(i),results.get(todo.get(i)))); | |
} | |
// take the shortest path off, repeat | |
// remove the one you just found | |
currentValue=valuesFound.poll().get(); | |
todo.remove(todo.indexOf(currentValue)); | |
output.add(currentValue); | |
} | |
return output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment