且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

500+个航路点/节点的最短路径算法(例如Dijkstra)?

更新时间:2022-04-15 23:23:20

直到尝试为止,您都不知道.

1000个节点实际上并不是那么多. Dijkstra的算法在边数上具有线性复杂度,而边数在节点数上则是二次方.从对图形的描述中,很难说出有多少条边,但是即使是全部1.000.000也不是很大.

1000 nodes isn't really that much. Dijkstra's algorithm has linear complexity in the number of edges and the number of edges is at worst quadratic in the number of nodes. From your description of the graph, it's hard to tell how many edges there are, but even the full 1.000.000 isn't very large.

主要问题是您可以使用

The main concern is that you implement it properly, using a priority queue.

修改: Russell& Norvig ,第二版,在第3章和第4章中介绍了一组通用搜索算法.它们所谓的统一成本图搜索本质上是Dijkstra的算法.如果遵循他们的指示,可以在需要时很容易地将算法扩展到A *搜索.

Edit: Russell & Norvig, 2nd ed., describe a set of generic search algorithms in chapter 3 and 4. What they call uniform cost graph search is essentially Dijkstra's algorithm. If you follow their instructions, you can extend the algorithm to A* search quite easily if the need arises.