Skip to content

Instantly share code, notes, and snippets.

@rgantt
Created July 20, 2011 03:04
Show Gist options
  • Save rgantt/1094247 to your computer and use it in GitHub Desktop.
Save rgantt/1094247 to your computer and use it in GitHub Desktop.
the subpath algorithm
/**
* visitedSoFar contains all nodes that have been traversed
* bestPathSoFar should be populated with only the subpath of visitedSoFar that contains no dead ends
*/
for( int j = 0; j < visitedSoFar.size(); j++ ) {
for( int i = visitedSoFar.size() - 1; i > j; i-- ) {
if( visitedSoFar.get( i ).equals( visitedSoFar.get( j ) ) ) {
j = i;
}
}
bestPathSoFar.add( visitedSoFar.get( j ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment