# 哈密顿路径问题

[哈密顿路径](https://www.edgepedia.org/zh/hamiltonian-path)问题是判定给定图是否包含哈密顿路径的判定问题，哈密顿路径是恰好访问每个顶点一次的简单路径。<sup>[1](https://www.sciencedirect.com/topics/computer-science/hamiltonian-path)</sup> 一个变体要求找出两个指定顶点之间的路径，而圈版本则问能否将这些顶点闭合成一个回到起点的圈。该问题是经典的NP完全问题之一，也是证明其他问题困难性的标准起点。<sup>[2](https://arxiv.org/abs/2205.05782)</sup>

| 关键事实 | 详情 |
|---|---|
| 定义 | 哈密顿路径是恰好访问图中每个顶点一次的简单路径；判定问题问的是这样的路径是否存在。<sup>[1](https://www.sciencedirect.com/topics/computer-science/hamiltonian-path)</sup> |
| 复杂性 | 对无向图、有向图和定向图均为NP完全。<sup>[2](https://arxiv.org/abs/2205.05782)</sup> |
| 经典地位 | 属于理查德·卡普（Richard Karp）1972年论文《组合问题之间的可归约性》中的21个NP完全问题。<sup>[3](https://researchr.org/publication/Karp72/bibtex)</sup> |
| 狄拉克条件（1952） | 一个有 \( n \ge 3 \) 个顶点、最小度 \( \delta(G) \ge n/2 \) 的图具有哈密顿圈。<sup>[4](https://opentext.uleth.ca/Combinatorics/sect_Euler-Hamilton.html)</sup> |
| 奥尔条件（1960） | 若对每一对不相邻顶点 \( u, v \) 都有 \( \deg(u) + \deg(v) \ge n \)，则该图具有哈密顿圈。<sup>[5](https://arxiv.org/abs/1403.0776)</sup> |
| 最佳通用精确算法 | 赫尔德–卡普子集动态规划，运行时间为 \( O(2^{n} n^{2}) \)。<sup>[6](https://arxiv.org/abs/2405.03018)</sup> |
| 困难图类 | 即使对一般网格图、平面图、圆图和有向路径图也是NP完全的。<sup>[7](https://www.sciencedirect.com/science/article/pii/S0304397517304759)</sup> |

## 定义与变体

图中的哈密顿路径是恰好经过其所有顶点一次的路径。<sup>[8](https://www.sciencedirect.com/science/article/abs/pii/S0022000025001369)</sup> 判定问题接受一个图，问这样的路径是否存在；s–t版本固定两个顶点，要求找出一条从一个顶点到另一个顶点的哈密顿路径。<sup>[9](https://doi.org/10.1016/j.disopt.2010.02.003)</sup> 有向版本对定向图提出同样的问题，其中每条边只能沿其指定方向通行。<sup>[10](https://www.math.stonybrook.edu/~tony/whatsnew/column/dna-0200/dna-abc2.html)</sup> 哈密顿圈还额外要求路径回到起始顶点。<sup>[11](https://www.cs.dartmouth.edu/~deepc/Courses/S09/Homework/hw3.pdf)</sup>

s–t哈密顿路径问题在各变体中居于核心地位：如果它对某一类图可在多项式时间内求解，那么通过检查所有顶点对，哈密顿路径、哈密顿圈和哈密顿连通性对该类图也可在多项式时间内求解。<sup>[8](https://www.sciencedirect.com/science/article/abs/pii/S0022000025001369)</sup>

## 计算复杂性

**NP完全性。** 哈密顿路径和哈密顿圈的存在性问题是众所周知的NP完全问题，在无向图、有向图和定向图中均是如此。<sup>[2](https://arxiv.org/abs/2205.05782)</sup> 卡普1972年的论文将哈密顿问题列入其21个自然的NP完全问题之中，这一结果帮助确立了[NP完全性](https://www.edgepedia.org/zh/np-completeness)作为组合问题广泛具有的性质。<sup>[3](https://researchr.org/publication/Karp72/bibtex)</sup><sup> • </sup><sup>[12](https://www.eulerfold.com/research-decoded/karp-combinatorial-problems)</sup> 有向s–t版本是从3-SAT进行标准归约的目标，其中公式的变量和子句被嵌入为小工具，通过变量小工具的可能路径对应于真值指派。<sup>[13](https://www.youtube.com/watch?v=4r78NtOnWWA)</sup>

即使在很强的限制下，困难性依然存在。该问题对一般网格图、平面图、[圆图](https://www.edgepedia.org/zh/circle-graph)和有向路径图仍然是NP完全的。<sup>[7](https://www.sciencedirect.com/science/article/pii/S0304397517304759)</sup> 贝尔托西（Bertossi）和博努切利（Bonuccelli）于1986年证明，哈密顿圈问题即使对无向路径图也是NP完全的。<sup>[14](https://arxiv.org/abs/0809.2443)</sup> 甚至判定一个图是否具有*唯一*哈密顿路径或圈，其复杂度在多项式意义下与布尔可满足性的唯一性问题（U-SAT）相同；这些唯一性问题是NP难的，属于DP类。<sup>[2](https://arxiv.org/abs/2205.05782)</sup>

**与相关问题的归约。** 哈密顿路径可归约到旅行商问题：给定一个图，可以构造一个带权完全图，使得TSP中是否存在有界长度巡游的问题回答了哈密顿问题。<sup>[15](https://opendsa.cs.vt.edu/ODSA/Books/duke/cs201/spring-2025/MW/html/hamiltonianCycle_to_TSP.html)</sup> 反过来，哈密顿s–t路径问题是近似算法困难性结果的标准来源，例如在带标签的旅行商问题中。<sup>[9](https://doi.org/10.1016/j.disopt.2010.02.003)</sup> 在描述复杂性中，加到一阶逻辑上的哈密顿路径算子恰好刻画NP，而判定两个指定顶点之间是否存在有向哈密顿路径在投影翻译下是NP完全的。<sup>[16](https://www.sciencedirect.com/science/article/pii/002200009290043I)</sup>

## 充分条件

由于未知简单的充要条件，且问题本身是NP完全的，图论学家发展了保证哈密顿性的条件，但这些条件并非必需。<sup>[8](https://www.sciencedirect.com/science/article/abs/pii/S0022000025001369)</sup>

**狄拉克定理。** [加布里埃尔·安德鲁·狄拉克](https://www.edgepedia.org/zh/gabriel-andrew-dirac)（Gabriel Andrew Dirac，1925–1984）于1952年证明，一个至少有三个顶点且最小价 \( \delta(G) \ge |V|/2 \) 的图具有哈密顿圈；该结果至今仍是证明一个图具有哈密顿圈的最有力已知方法之一。<sup>[4](https://opentext.uleth.ca/Combinatorics/sect_Euler-Hamilton.html)</sup> 该界在一种意义上是紧的：若最小度仅为 \( (p-1)/2 \)，结论不成立，任何完全二部图 \( K_{d,d+1} \) 都是反例。<sup>[17](https://www.math.wm.edu/~rrkinc/homework/HamSuff.pdf)</sup> 然而该条件远非必要，因为一个五阶或更高阶的单一圈不满足任何高度数条件，却本身就是哈密顿圈。<sup>[17](https://www.math.wm.edu/~rrkinc/homework/HamSuff.pdf)</sup>

**奥尔定理。** 1960年，[厄于斯泰因·奥尔](https://www.edgepedia.org/zh/ystein-ore)（Øystein Ore）放松了狄拉克的度条件：每个对每条非边 \( uv \) 都有 \( \deg(u) + \deg(v) \ge n \) 的图都包含哈密顿圈。<sup>[5](https://arxiv.org/abs/1403.0776)</sup> 狄拉克定理可由奥尔定理推出，因为最小度为 \( n/2 \) 迫使每个度和达到 \( n \)，而有些图满足奥尔条件却不满足狄拉克条件。<sup>[17](https://www.math.wm.edu/~rrkinc/homework/HamSuff.pdf)</sup> 一个座位谜题给出了标准解释：如果 \( p \) 个人中每个人至少与 \( p/2 \) 个人是朋友，那么客人可以围桌而坐，使每个人都坐在两个朋友之间。<sup>[17](https://www.math.wm.edu/~rrkinc/homework/HamSuff.pdf)</sup>

**闭包。** 1976年，约翰·阿德里安·邦迪（John Adrian Bondy）和[瓦茨拉夫·赫瓦塔尔](https://www.edgepedia.org/zh/vaclav-chvatal)（Václav Chvátal）注意到狄拉克的证明建立了一个更强的引理：若 \( u \) 和 \( v \) 是一个 \( n \) 顶点图中不相邻的顶点且 \( d(u) + d(v) \ge n \)，则该图有哈密顿圈当且仅当添加边 \( uv \) 后的图有哈密顿圈。反复添加这样的边得到图的唯一闭包，这给出了一个涵盖狄拉克定理和奥尔定理的通用检验方法。<sup>[4](https://opentext.uleth.ca/Combinatorics/sect_Euler-Hamilton.html)</sup>

## 算法

**精确指数算法。** 由迈克尔·赫尔德（Michael Held）和理查德·卡普于1962年提出的赫尔德–卡普动态规划，通过在完全带权图上计算 \( dp(S, i) \)——即恰好访问子集 \( S \) 中的顶点并终止于 \( i \) 的最短路径——来求解最短哈密顿路径和圈问题，递推式为 \( dp(S, i) = \min_{j}(dp(S \setminus \{i\}, j) + w(j, i)) \)。其运行时间为 \( O(2^{n} n^{2}) \)，这一界六十年未经改进，直到2024年一个算法达到了 \( 2^{n} n^{2} / 2^{\Omega(\sqrt{\log n})} \)。<sup>[18](https://algorithms.alexli.ca/shortest-hamiltonian-path-and-cycle-held-karp/)</sup><sup> • </sup><sup>[6](https://arxiv.org/abs/2405.03018)</sup> 对于计数而非寻找路径，埃里克·T·巴克斯（Eric T. Bax）1993年的容斥算法在 \( O(2^{n} \times n^{4}) \) 时间内、使用 \( O(n^{3} \log_{2} n) \) 比特存储，确定具有给定起点和终点的哈密顿路径数目。<sup>[19](https://www.sciencedirect.com/science/article/pii/0020019093900336)</sup>

**参数化与受限情形。** 输入中的[结构](https://www.edgepedia.org/zh/structure)会改变局面。在树深为 \( d \) 的图上，哈密顿圈、哈密顿路径、长圈、长路径和最小圈覆盖都容许使用多项式空间的随机 \( 5^{d} \cdot n^{\mathcal{O}(1)} \) 时间算法，回答了黑格费尔德（Hegerfeld）和克拉奇（Kratsch）的一个未解决问题。<sup>[20](https://arxiv.org/abs/2002.04368)</sup> 在带矩形孔且大小为偶数的矩形网格图上，哈密顿(s,t)-路径可在线性时间内找到，尽管该问题对一般网格图是NP完全的。<sup>[7](https://www.sciencedirect.com/science/article/pii/S0304397517304759)</sup> 相比之下，列表哈密顿路径即使以路径宽度为参数也是W[1]-难的。<sup>[21](https://www.sciencedirect.com/science/article/pii/S0890540116300542)</sup>

**启发式方法与分子计算。** 1985年的Minram算法将哈密顿路径视为分支指数为零的生成树形图，并使用枢轴来最小化该指数；它在多达1000个节点的随机生成哈密顿图上以高成功率找到哈密顿路径。<sup>[22](https://www.sciencedirect.com/science/article/pii/0166218X85900113)</sup> 该问题在非常规计算史上也占有一席之地：1994年[伦纳德·阿德曼](https://www.edgepedia.org/zh/leonard-adleman)（Leonard Adleman）在试管中通过处理DNA链求解了一个哈密顿路径问题实例，后来的分子算法将所需DNA体积从阿德曼的 \( n! \) 降至多项式时间的 \( O(2^{n} n^{2} \log^{2} n) \) 体积，用于计数哈密顿路径。<sup>[23](https://www.sciencedirect.com/science/article/abs/pii/S0303264799000490)</sup>

## 应用

哈密顿路径模拟任何要求按连通序列恰好访问集合中每个项目一次的需求。安排客人就座使相邻者相识直接对应于寻找哈密顿圈，而安排队列使连续的人彼此认识则对应于路径版本。<sup>[24](https://www.youtube.com/watch?v=293VwVMOiRU)</sup> [卫星](https://www.edgepedia.org/zh/satellite)调度和开放式路径问题被表述为哈密顿路径搜索，而旅行商问题的开放巡游版本——其中代理无需返回起点——正是一个最短哈密顿路径问题。<sup>[25](https://clas.ucdenver.edu/mathematical-and-statistical-sciences/sites/default/files/attached-files/clinicreportspring2006.pdf)</sup>

## References

1. [Hamiltonian Path – an overview, ScienceDirect Topics](https://www.sciencedirect.com/topics/computer-science/hamiltonian-path)
2. [On the Complexity of Determining Whether there is a Unique Hamiltonian Cycle or Path (arXiv:2205.05782)](https://arxiv.org/abs/2205.05782)
3. [Richard M. Karp, Reducibility Among Combinatorial Problems (1972), researchr bibliography](https://researchr.org/publication/Karp72/bibtex)
4. [Hamilton paths and cycles, Open Textbook (University of Lethbridge Combinatorics)](https://opentext.uleth.ca/Combinatorics/sect_Euler-Hamilton.html)
5. [Ore-degree threshold for the square of a Hamiltonian cycle (arXiv:1403.0776)](https://arxiv.org/abs/1403.0776)
6. [TSP Escapes the O(2^n n^2) Curse (arXiv:2405.03018)](https://arxiv.org/abs/2405.03018)
7. [A linear-time algorithm for finding Hamiltonian (s,t)-paths in even-sized rectangular grid graphs with a rectangular hole, Theoretical Computer Science](https://www.sciencedirect.com/science/article/pii/S0304397517304759)
8. [On the structure of Hamiltonian graphs with small independence number, Journal of Computer and System Systems](https://www.sciencedirect.com/science/article/abs/pii/S0022000025001369)
9. [Labeled Traveling Salesman Problems: Complexity and approximation, Discrete Optimization](https://doi.org/10.1016/j.disopt.2010.02.003)
10. [The ABC of DNA Computing, Stony Brook Mathematics](https://www.math.stonybrook.edu/~tony/whatsnew/column/dna-0200/dna-abc2.html)
11. [Scheduling Theory, CO 454 homework, Dartmouth College](https://www.cs.dartmouth.edu/~deepc/Courses/S09/Homework/hw3.pdf)
12. [Karp's 21 NP-Complete Problems, Eulerfold](https://www.eulerfold.com/research-decoded/karp-combinatorial-problems)
13. [Hamiltonian Path is NP-Complete (Directed, Reduction from 3SAT), Easy Theory (YouTube)](https://www.youtube.com/watch?v=4r78NtOnWWA)
14. [NP-Completeness of Hamiltonian Cycle Problem on Rooted Directed Path Graphs (arXiv:0809.2443)](https://arxiv.org/abs/0809.2443)
15. [Reduction of Hamiltonian Cycle to Traveling Salesman, OpenDSA](https://opendsa.cs.vt.edu/ODSA/Books/duke/cs201/spring-2025/MW/html/hamiltonianCycle_to_TSP.html)
16. [Using the Hamiltonian path operator to capture NP, Journal of Computer and System Sciences](https://www.sciencedirect.com/science/article/pii/002200009290043I)
17. [Sufficient Conditions for Hamiltonian Graphs, William & Mary lecture notes](https://www.math.wm.edu/~rrkinc/homework/HamSuff.pdf)
18. [Shortest Hamiltonian Path and Cycle (Held-Karp), Algorithms library documentation](https://algorithms.alexli.ca/shortest-hamiltonian-path-and-cycle-held-karp/)
19. [Eric T. Bax, Inclusion and exclusion algorithm for the Hamiltonian path problem, Information Processing Letters 47 (1993)](https://www.sciencedirect.com/science/article/pii/0020019093900336)
20. [Hamiltonian Cycle Parameterized by Treedepth in Single Exponential Time and Polynomial Space (arXiv:2002.04368)](https://arxiv.org/abs/2002.04368)
21. [The parameterised complexity of list problems on graphs of bounded treewidth, Information and Computation](https://www.sciencedirect.com/science/article/pii/S0890540116300542)
22. [A successful algorithm for the undirected Hamiltonian path problem, Discrete Applied Mathematics 10 (1985)](https://www.sciencedirect.com/science/article/pii/0166218X85900113)
23. [An Õ(2^n) volume molecular algorithm for Hamiltonian path, Biosystems](https://www.sciencedirect.com/science/article/abs/pii/S0303264799000490)
24. [S6.10 – Dirac and Ore's Theorems, Universitat Politècnica de València (YouTube)](https://www.youtube.com/watch?v=293VwVMOiRU)
25. [Clinic Report, University of Colorado Denver, Mathematical and Statistical Sciences](https://clas.ucdenver.edu/mathematical-and-statistical-sciences/sites/default/files/attached-files/clinicreportspring2006.pdf)

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

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Algorithms and computational methods › Graph and network algorithms › Hard graph problems and heuristics

Copyright 2026 Edgepedia

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

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

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