Probably better to use the
Floyd-Warshall APSP (all-points-shortest-path) algorithm. This gives you all the shortest paths from all the possible origins to all the possible destinations, which I think is what you want.
On the other hand, it's rather confusing to work with. If you're going to need to fine tune it, and you may want to, then I wouldn't recommend it unless you have a lot of experience with search algorithms, you're a really smart programmer, or you have an uncommonly strong imagination for multi-dimensional geometry. (Failing at all three of those myself, I find it difficult to work with.
)
If you haven't written a search algorithm before, I would not recommend Dijkstra's either. Instead I'd say use the simpler
"breadth first" search.
It will be easy to get it working, and you can fine-tune it after that. Once you're done fine-tuning it, it will arguably look something like Dijkstra's. (Dijkstra's is a breadth-first search but with an extra consideration: some connections are costlier than others.) But if you're just starting out, I think it would be easier for you to add small sophistications to a simpler algorithm, rather than adjust a more complicated algorithm.
If it's just a modder's tool, to analyze star-system files and produce the shortest-paths file, then I wouldn't see any urgent need to optimize the tool for processing speed. (If there were, you'd be using Floyd-Warshall anyway.) But if this were a concern, and you were using a breadth-first approach, you'd want to use a heuristic to cancel obviously-bad paths before they're added to the queue. (When you do this with Dijkstra, you get what is called the
A-star algorithm.)
Well let me know if you need any further advice, or if you get into trouble. This is one of my few areas of specialization, and I'm always happy to help.
Edited by - breslin on 9/18/2007 5:47:01 AM