Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in possibleRoutes, p. 124 #22

Open
ghost opened this issue Sep 17, 2012 · 0 comments
Open

Error in possibleRoutes, p. 124 #22

ghost opened this issue Sep 17, 2012 · 0 comments

Comments

@ghost
Copy link

ghost commented Sep 17, 2012

I believe there is an error in the algorithm for possibleRoutes. It can't handle routes that reach a dead end on the map. If you have this route: Point Teo->Puama->Mt Ootua->Hanapaoa, you're at a dead end. At this point the expression "_filter roadsFrom(end), notVisited" returns an empty array. That array is then mapped over with "continueRoute". From an ampty array the only element you can map over is "undefined", referencing the "to" property of, results in a runtime exception:
TypeError: Cannot read property 'length' of undefined.

I think the general idea of transforming a graph to a tree (which this example tries to achieve, I think) needs to apply some form of backtracking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants