Created
July 20, 2011 03:04
-
-
Save rgantt/1094247 to your computer and use it in GitHub Desktop.
the subpath algorithm
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
/** | |
* 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