Sign in to follow this  
eknathiyer

help reqd in path finding algorthms

Recommended Posts

Hi, Following is my problem: Given is a matrix with a label for each vertex saying it is a "danger spot" or a "safe spot". Also the starting and destination vertex are provided at run time. I need to figure out the quickest route possible with this given input. Any suggestions as to which algorithm I should use?

Share this post


Link to post
Share on other sites
By a "matrix", I assume you mean you're pathing on a 2D grid? A* is the most commonly used algorithm for this sort of thing.

Share this post


Link to post
Share on other sites
Quote:
Or you could also try Dijkstra's Shortest Path algorithm
My understanding is that A* is a variation of Dijkstra. A* incorporates a heuristic, which causes it to perform better than Dijkstra in the general case. However, there are cases where a meaningful heuristic may not be available, in which case Dijkstra is the better choice.

So in other words, A* vs. Dijkstra isn't really a 'six of one, half dozen of the other' choice; they have different characteristics and different uses.

Given the information that the OP provided, it seems pretty clear that A* is the better choice in this case (unless I've overlooked something).

Share this post


Link to post
Share on other sites
Just figured it would be easier for OP to understand and find a working Dijkstra's then try to get A* working (its just a breadth first search with a heuristic anyway as you point out), but for a beginner DSP might be easier.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this