Created
October 31, 2009 15:43
-
-
Save erikbgithub/223108 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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