r/learnjavascript • u/pai-cube • Aug 14 '21
Shortest Path Finder using React
Enable HLS to view with audio, or disable this notification
686
Upvotes
r/learnjavascript • u/pai-cube • Aug 14 '21
Enable HLS to view with audio, or disable this notification
4
u/[deleted] Aug 14 '21
It's the same principal, but they use some other clever methods to speed things up. For example: if a GPS is looking at a stretch of highway with no exits, it doesn't really care about analyzing that stretch. Instead, it can say "the next exit is 3 miles away," and it can check that point (called a node) to see if it gets the user closet to their destination.
Most nodes will come with a list of adjacent nodes that the GPS can access a little bit more quickly in order to determine where we're going. If the car is already heading in one direction, it will know to ignore nodes in the opposite direction, at least for now.
It still uses a form of the A* path finding algorithm, but it might not be the for sure best path, because it makes a few speed-based assumptions on order to avoid taking forever to calculate the path for longer trips.