evenfurther / pathfinding

Pathfinding library for rust
856 stars 71 forks source link

dfs `start` type is inconsistent with the rest #4

Closed tko closed 7 years ago

tko commented 7 years ago

Not sure if intentional, but all the other algorithms take &N as the starting point, only dfs takes N

samueltardieu commented 7 years ago

Yes, this is intentional: contrary to astar/dijkstra/bfs/fringe, elements discovered during a dfs search (such as neighbours returned by the appropriate closure) are stored only in the path, and never in other lists. This allows the use of non-Clone types. However, it requires that we take ownership of start as to be able to insert it into the resulting Vec.

There is already a note to that effect in the documentation:

Note that the start node ownership is taken by dfs as no clones are made.