跳到主要内容
Z

Dijkstra vs A*

Dijkstra vs A* compared — heuristics, speed, optimality and use cases, with interactive pathfinding visualizers.

Dijkstra finds shortest paths from a source to every node; A* adds a heuristic that aims at a single goal, exploring far fewer nodes. A* with a good heuristic is Dijkstra, only smarter about direction.

Dijkstra vs A* at a glance

Dijkstra A*
Heuristic None Yes (estimate to goal)
Target All nodes One goal
Nodes explored More Fewer
Optimal Yes Yes (admissible heuristic)

When to use Dijkstra

Use Dijkstra for shortest paths to all nodes or when no good heuristic exists.

When to use A*

Use A* for point-to-point pathfinding where you can estimate distance to the goal.

Tools for Dijkstra & A*

Dijkstra vs A*

递归分割算法是如何生成迷宫的?

它从一个空白区域开始,然后递归地用一堵带有随机缺口的直墙分割每个空间,如此反复,直到空间小到无法继续分割。

什么是「完美迷宫」?

指任意两个格子之间有且仅有一条路径的迷宫——没有环路,也没有孤立区域。递归分割算法生成的始终是完美迷宫。

我可以求解这个迷宫吗?

可以——把这个布局复制到 BFS、Dijkstra 或 A* 可视化工具中(它们使用相同的方格网格),即可查看寻路算法如何穿过它。

还有哪些其他的迷宫生成算法?

递归回溯(随机化 DFS)、Prim 算法、Kruskal 算法、Wilson 算法和 Eller 算法——每种算法生成的迷宫在视觉结构上都各具特色。