# 最短路径问题

最短路径问题，是在带权图中寻找两个顶点之间边权之和尽可能小的一条路径的问题。它是算法领域最经典的问题之一，研究变体包括固定单源、单对或全对顶点，并且是路由、网络优化和寻路系统的基础。<sup>[1](https://arxiv.org/abs/2609.15247)</sup><sup> • </sup><sup>[2](https://networkx.org/documentation/latest/reference/algorithms/shortest_paths/dijkstra.html)</sup>

| 关键事实 | 详情 |
|---|---|
| 标准变体 | 单源（一个顶点到其余所有顶点）、单对和全对；BFS、Dijkstra 和 Bellman–Ford 服务于前两者，Floyd–Warshall 和 Johnson 服务于后者<sup>[3](https://networkx.org/documentation/stable/reference/algorithms/shortest_paths.html?trk=article-ssr-frontend-pulse_little-text-block)</sup> |
| Dijkstra 算法 | 要求边权非负；使用数组时运行时间为 \( O(|V|^{2}) \)，使用二叉堆时为 \( O((|V| + |E|) \log |V|) \)，使用斐波那契堆时为 \( O(|V| \log |V| + |E|) \)<sup>[2](https://networkx.org/documentation/latest/reference/algorithms/shortest_paths/dijkstra.html)</sup> |
| Bellman–Ford | 能处理负边权，运行时间为 \( O(|V| \cdot |E|) \)，并能检测从源点可达的负权环<sup>[3](https://networkx.org/documentation/stable/reference/algorithms/shortest_paths.html?trk=article-ssr-frontend-pulse_little-text-block)</sup><sup> • </sup><sup>[4](https://twiki.di.uniroma1.it/pub/Algoreti/ProgrammaDelCorso/1_1_SingleSourceShortestPaths.pdf)</sup>  |
| 环 | 最短路径绝不会包含正权环；零权环可以在不改变权重的情况下移除，因此可以假定最短路径无环<sup>[4](https://twiki.di.uniroma1.it/pub/Algoreti/ProgrammaDelCorso/1_1_SingleSourceShortestPaths.pdf)</sup> |
| 负环 | 如果从源点可达一个负权环，则最短路径权重无定义，因为绕环循环会无界地降低成本<sup>[5](https://mitocw.ups.edu.ec/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/lecture-videos/lecture-17-bellman-ford/)</sup> |
| 2025 年突破 | 一个确定性 \( O(m \log^{2/3} n) \) 算法，用于非负权有向单源最短路径，是首个在稀疏图上打破 Dijkstra \( O(m + n \log n) \) 界的算法<sup>[6](https://arxiv.org/abs/2504.17033)</sup> |
| 实用路由 | 收缩层次结构可在数百万节点的路网上以毫秒级回答查询，代价是 \( O(n^{2}) \) 的预处理空间和时间<sup>[7](https://arxiv.org/abs/1304.2576)</sup> |

## 问题定义与环

给定一个图 \( G = (V, E) \)，每条边带有权重 \( w(u, v) \)，路径的权重是其边权之和，最短路径问题要求找出指定顶点之间权重最小的路径。查询类型很重要：单源计算找出从一个顶点到所有可达顶点的路径，单对查询找出两个顶点之间的一条路径，全对计算找出每一对顶点之间的路径。距离查询只返回最小总权重，而最短路径查询返回路线本身。<sup>[3](https://networkx.org/documentation/stable/reference/algorithms/shortest_paths.html?trk=article-ssr-frontend-pulse_little-text-block)</sup><sup> • </sup><sup>[7](https://arxiv.org/abs/1304.2576)</sup>

**最短路径中的环。** 最短路径不能包含负权环，也不能包含正权环，因为从路径中删除该环会保持端点不变并降低权重。零权环是无害的：从最短路径中移除一个零权环会留下另一条权重相同的路径，因此只要最短路径存在，就也存在一条无环（简单）最短路径。<sup>[4](https://twiki.di.uniroma1.it/pub/Algoreti/ProgrammaDelCorso/1_1_SingleSourceShortestPaths.pdf)</sup> 负权环才是真正具有破坏性的情况。如果从源点可达这样的环，那么通过走到该环并无限绕行即可达到最小权重，因此最短路径权重毫无意义；正确的算法必须检测并报告该环，而不是返回一个数字。<sup>[8](https://www.cs.mun.ca/~kol/courses/6901-f16/lec8.pdf)</sup><sup> • </sup><sup>[5](https://mitocw.ups.edu.ec/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/lecture-videos/lecture-17-bellman-ford/)</sup>

## Dijkstra 算法

Dijkstra 算法由 Edsger W. Dijkstra 于 1959 年发表在《Numerische Mathematik》上的一篇三页短文中提出（第 269–271 页），用于在所有边权非负时求解单源问题。<sup>[9](https://doi.org/10.1007/BF01386390)</sup> 它是一种贪心的迭代方法：为每个顶点维护一个暂定距离，反复选择暂定距离最小的未访问顶点，将该距离标记为最终值，并松弛该顶点的出边，只要经过所选顶点会更短，就更新邻居的暂定距离。<sup>[2](https://networkx.org/documentation/latest/reference/algorithms/shortest_paths/dijkstra.html)</sup>

非负性假设正是使贪心步骤安全的原因：一旦某个顶点以最小的暂定距离被取出，之后任何路径都不可能更短。在有负权时这一点不成立。在一个标准反例中，从 s 到 t 的一条权重为 5 的直接边，与一条两段路径竞争：s 到 v 权重为 10，然后 v 到 t 权重为 −7，总计为 3；Dijkstra 算法在距离 5 处将 t 定为最终值，并且永远不会更正它。<sup>[8](https://www.cs.mun.ca/~kol/courses/6901-f16/lec8.pdf)</sup> 给每条边权加上一个常数使它们非负并不能修复该算法，因为边数不同的路径会被平移不同的量。<sup>[10](https://www2.seas.gwu.edu/~simhaweb/cs151/lectures/module9/module9.html)</sup>

## 负权与 Bellman–Ford

Bellman–Ford 算法在边权为负时求解单源问题，只要从源点不可达负权环即可。它反复松弛所有边，经过足够多轮之后，要么距离稳定下来，要么检测并报告一个负环，在这种情况下受影响的最短路径计算被中止。<sup>[4](https://twiki.di.uniroma1.it/pub/Algoreti/ProgrammaDelCorso/1_1_SingleSourceShortestPaths.pdf)</sup><sup> • </sup><sup>[5](https://mitocw.ups.edu.ec/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/lecture-videos/lecture-17-bellman-ford/)</sup>  其 \( O(|V| \cdot |E|) \) 运行时间作为教科书上的界保持了 60 多年；2019 年的一个算法打破了它，方法是通过最多 \( \min(\sqrt{n}, \sqrt{m/\log n}) \) 次调用 Dijkstra 算法将输入图转换为非负权重，同时保持最短路径树。<sup>[11](https://arxiv.org/abs/1905.01325)</sup>

两个结构性特例避免了通用负权搜索的代价。在有向无环图（DAG）中，由于不存在任何类型的环，一个简单算法即可处理负边权。<sup>[12](https://cs61b-2.gitbook.io/cs61b-textbook-spring-2026/23.-reductions-and-decomposition/23.2-shortest-paths-on-dags)</sup> 在无向图中，有向归约技术在负权下会失效，即使不存在负环也是如此，该问题转而通过归约到带权非二部匹配来求解。<sup>[13](https://www.cs.princeton.edu/courses/archive/fall14/cos226/lectures/65Reductions.pdf)</sup>

## 全对与重赋权

对于全对最短路径，Floyd–Warshall 运行时间为 \( O(|V|^{3}) \)，适合稠密图，而 Johnson 算法针对带负权的稀疏图：它运行一次 Bellman–Ford 来计算一个价格向量，将每条边重赋权为非负，然后从每个顶点应用 Dijkstra 算法。<sup>[3](https://networkx.org/documentation/stable/reference/algorithms/shortest_paths.html?trk=article-ssr-frontend-pulse_little-text-block)</sup><sup> • </sup><sup>[14](https://arxiv.org/abs/2109.01872)</sup>  当不存在负边时，从每个顶点运行 Dijkstra 在稀疏图上比 Floyd–Warshall 效果更好。<sup>[14](https://arxiv.org/abs/2109.01872)</sup>

## 近期理论进展

几十年来，在比较-加法模型中，非负单源最短路径的最佳界是使用斐波那契堆的 Dijkstra \( O(m + n \log n) \)。2025 年，段然、毛嘉怡、毛啸、舒新凯和尹龙辉给出了一个有向图的确定性 \( O(m \log^{2/3} n) \) 时间算法，这是首个在稀疏图上打破该界、并表明 Dijkstra 算法对该问题并非最优的算法。<sup>[6](https://arxiv.org/abs/2504.17033)</sup><sup> • </sup><sup>[1](https://arxiv.org/abs/2609.15247)</sup>  2026 年，一个成员有重叠的团队将这一有向界改进为 \( O(m \sqrt{\log n} + \sqrt{mn \log n \log \log n}) \)，对于稀疏图即为 \( O(m \sqrt{\log n \log \log n}) \)。<sup>[15](https://arxiv.org/abs/2602.07868)</sup> 对于无向图，一个随机化的 \( O(m \log^{1/2} n \log\log^{1/2} n) \) 算法已于 FOCS 2023 出现，此后又有进一步的改进。<sup>[1](https://arxiv.org/abs/2609.15247)</sup>

负权最短路径也进展迅速。2025 年的一个算法给出了首个针对带负整数权有向图的确定性近线性时间解，运行时间为 \( \tilde{O}(m) \cdot \log(nW) \)，可以计算所有距离或报告一个负环；它引入了一个称为路径覆盖的结构性原语。<sup>[16](https://arxiv.org/abs/2511.08551)</sup> 一个具有近线性 \( \tilde{O}(m) \) 工作量的并行随机化算法，用于一般图中带负权的单源最短路径，已在 SOSA 2025 出现。<sup>[17](https://epubs.siam.org/doi/10.1137/1.9781611978315.17)</sup> 这些渐近优势在实践中并未取代经典方法：基准测试报告称，经过良好调优的 Dijkstra 在真实世界图上仍然快 3 到 4 倍，因为新算法具有较大的常数因子。<sup>[18](https://www.danilchenko.dev/posts/faster-than-dijkstra/)</sup>

## 应用

最短路径计算是路线规划的形式核心：在路网中，节点表示交叉口，边携带通行时间，为用户规划路线就是一个最短路径查询。<sup>[19](https://arxiv.org/abs/1910.12526)</sup> 普通的 Dijkstra 对于大陆规模的网络来说太慢，因此加速技术在实践中占主导地位。收缩层次结构在预处理步骤中插入捷径边，并在数百万节点的网络上以毫秒级回答查询，尽管其 \( O(n^{2}) \) 的预处理代价在渐近意义上比 Dijkstra 算法本身还差。<sup>[7](https://arxiv.org/abs/1304.2576)</sup> 干线层次索引（Arterial Hierarchy）在大约三小时内预处理一个拥有 2300 万节点的大陆规模网络，生成不超过 32 GB 的索引，并在 \( \tilde{O}(\log \alpha) \) 时间内回答距离查询，其中 \( \alpha = d_{max}/d_{min} \) 是节点间最大与最小 \( L_{\infty} \) 距离之比。<sup>[7](https://arxiv.org/abs/1304.2576)</sup> A* 搜索通过一个距离估计启发式来加速 Dijkstra，支持实时交通和转向限制等扩展场景，其实现复杂度低于扩展层次结构技术。<sup>[19](https://arxiv.org/abs/1910.12526)</sup>

除导航之外，最短路径算法还是地理信息系统中用于供应链优化的标准工具，与旅行商问题和车辆路径问题并列；最短路径算法在位置网络中搜索起点与目的地之间成本最低的路径。<sup>[20](https://www.gis.fhwa.dot.gov/newsletters/Newsletter_February2022.aspx)</sup> 一项针对最短路径优化的 Dijkstra 与 Bellman–Ford 比较研究发现，Dijkstra 在执行时间上更优、整体效率更高，但需要注意的是它仅适用于非负边权。<sup>[21](https://doi.org/10.1088/1757-899X%2F917%2F1%2F012077)</sup>

## References

1. [A Faster Undirected Single-Source Shortest Path Algorithm (arXiv:2609.15247)](https://arxiv.org/abs/2609.15247)
2. [Dijkstra's Algorithm, NetworkX documentation](https://networkx.org/documentation/latest/reference/algorithms/shortest_paths/dijkstra.html)
3. [Shortest Paths, NetworkX documentation](https://networkx.org/documentation/stable/reference/algorithms/shortest_paths.html?trk=article-ssr-frontend-pulse_little-text-block)
4. [Cormen, Leiserson, Rivest, Stein, Introduction to Algorithms, 3rd ed., Chapter 24: Single-Source Shortest Paths (course excerpt)](https://twiki.di.uniroma1.it/pub/Algoreti/ProgrammaDelCorso/1_1_SingleSourceShortestPaths.pdf)
5. [Lecture 17: Bellman-Ford, MIT 6.006 Introduction to Algorithms, MIT OpenCourseWare](https://mitocw.ups.edu.ec/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/lecture-videos/lecture-17-bellman-ford/)
6. [Duan, Mao, Mao, Shu, Yin (2025). Breaking the Sorting Barrier for Directed Single-Source Shortest Paths. arXiv:2504.17033](https://arxiv.org/abs/2504.17033)
7. [Zhu et al. (2013). Shortest Path and Distance Queries on Road Networks: Towards Bridging Theory and Practice. arXiv:1304.2576](https://arxiv.org/abs/1304.2576)
8. [Kolokolova, A. (2016). CS 6901 Applied Algorithms, Lecture 8: Single-source shortest path with negative weights/cycles](https://www.cs.mun.ca/~kol/courses/6901-f16/lec8.pdf)
9. [Dijkstra, E. W. (1959). A note on two problems in connexion with graphs. Numerische Mathematik 1, 269–271](https://doi.org/10.1007/BF01386390)
10. [Module 9: Shortest Paths and Dynamic Programming, Algorithms and Data Structures II, George Washington University](https://www2.seas.gwu.edu/~simhaweb/cs151/lectures/module9/module9.html)
11. [Breaking the Bellman-Ford Shortest-Path Bound (arXiv:1905.01325)](https://arxiv.org/abs/1905.01325)
12. [Shortest Paths on DAGs, CS61B Textbook Spring 2026](https://cs61b-2.gitbook.io/cs61b-textbook-spring-2026/23.-reductions-and-decomposition/23.2-shortest-paths-on-dags)
13. [Reductions, COS 226 Lecture 6.5, Princeton University](https://www.cs.princeton.edu/courses/archive/fall14/cos226/lectures/65Reductions.pdf)
14. [Improving The Floyd-Warshall All Pairs Shortest Paths Algorithm (arXiv:2109.01872)](https://arxiv.org/abs/2109.01872)
15. [Duan, Mao, Shu, Yin (2026). A Faster Directed Single-Source Shortest Path Algorithm. arXiv:2602.07868](https://arxiv.org/abs/2602.07868)
16. [Haeupler, Jiang, Saranurak (2025). Deterministic Negative-Weight Shortest Paths in Nearly Linear Time via Path Covers. arXiv:2511.08551](https://arxiv.org/abs/2511.08551)
17. [Fischer, Haeupler, Latypov, Roeyskoe, Sulser (2025). A Simple Parallel Algorithm with Near-Linear Work for Negative-Weight Single-Source Shortest Path. SOSA 2025](https://epubs.siam.org/doi/10.1137/1.9781611978315.17)
18. [Faster Than Dijkstra: New Shortest-Path Algorithm Explained](https://www.danilchenko.dev/posts/faster-than-dijkstra/)
19. [Strasser, B., Zeitz, T. (2021). A Fast and Tight Heuristic for A* in Road Networks. arXiv:1910.12526](https://arxiv.org/abs/1910.12526)
20. [GIS in Transportation Newsletter, February 2022, Federal Highway Administration](https://www.gis.fhwa.dot.gov/newsletters/Newsletter_February2022.aspx)
21. [Comparative Analysis between Dijkstra and Bellman-Ford Algorithms in Shortest Path Optimization, IOPscience](https://doi.org/10.1088/1757-899X%2F917%2F1%2F012077)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 逻辑与离散数学 › General discrete mathematics and discrete structures › Graph theory › Computational graph problems and algorithms › Shortest-path problems and algorithms

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/shortest-path-problem

English original: https://www.edgepedia.org/shortest-path-problem
