Question
In the context of this exercise, for the find_path
method algorithm, does the order we’re removing the vertices matter?
Answer
For this implementation of the pathfinding algorithm, no, the order that the vertices are removed does not matter. This is mainly because the method is only concerned with whether there is any path between two points, and not which is the longest or the shortest.
For other pathfinding algorithms, the order of vertices being removed and checked can matter. For example, one pathfinding algorithm, known as the “A-star algorithm”, utilizes a technique to find a path between two points on a grid, possibly filled with obstacles. The technique works by first checking the points that appear the closest to the target point. If instead, it checked the points in some different order, then the algorithm would not be as effective.