Full description of the file
Download the source and implementation code of A* algorithm in C#
Some time ago I had to make a project to determine the shortest path inside a matrix. "Nothing beats routing for this," I thought to myself. There are a lot of links and explanations about Path Finding, but I couldn't find a version written in C# that could meet my needs. So, I decided to implement A* in C#. This code was really helpful for me and I bet it can be helpful for many other people too. I won't explain the implementation of the algorithm too much because just typing "A* routing algorithm" into Google will bring up tons of documentation where you can find every single detail.
About the program
A* is a general algorithm and there are no absolute parameters to set. The algorithm has many things that can be adjusted, so the best way to determine the right parameters for your project is to experiment with different combinations. As a note: usually a good A* implementation does not use the standard ArrayList or List for open nodes. If a standard list is used, the algorithm spends a lot of time searching for nodes in that list. Instead, a priority queue should be used. I borrowed the code from BenDi to implement the priority queue. I modified it a bit and also changed the implementation to use Generics instead of ArrayList which makes it run faster. This project is really useful for two reasons.
- I followed the A* implementation and tried to implement it to perform well, so the algorithm itself can be easily reused in any project.
- The front end gives a full opportunity to experiment with many variables where you can actually watch and learn how it works, change heuristics, formulas or options to analyze the best settings for your project.
Dear user, you are offered a download.