Skip to content

Instantly share code, notes, and snippets.

@erikbgithub
Created October 31, 2009 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erikbgithub/223108 to your computer and use it in GitHub Desktop.
Save erikbgithub/223108 to your computer and use it in GitHub Desktop.
public List getRoute(myNode start, myNode end){
//initialise variables
myNode actual = end;
myNodeList wayBack = new myNodeList();
wayBack.add(end);
myNodeList way = new myNodeList();
//find the minimum spanning tree with end
myNodeMap map = this.spanner.span(this.g, start);
//get a list from end to start
while(!start.equals(actual)){
actual = map.get(actual);
wayBack.add(actual);
}
//revert list
while(!wayBack.isEmpty()){
way.add(wayBack.removeLast());
}
return way;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment