Skip to content

Error in possibleRoutes, p. 124 #22

@ghost

Description

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions