跳到主要内容

资源 · 指南或文章

Hamiltonian Path

讲解哈密顿路径和哈密顿回路(每个顶点恰好访问一次),以及两种搜索方法:暴力枚举和回溯。

审核日期

打开原站: Hamiltonian Path (在新标签页中打开原网站)

练习这个主题打开练习面试官,并带上一道关于 图 的题目。

添加到路线图

把这个资源放进你正在跟进的路线图。它会作为你自己的补充资源显示;路线图的步骤不会改变,也不计入你已记录的步骤。

来源内容语言:英语

Hamiltonian path (or traceable path) is a path in an undirected or directed graph that visits each vertex exactly once. A Hamiltonian cycle (or Hamiltonian circuit) is a Hamiltonian path that is a cycle. Determining whether such paths and cycles exist in graphs is the Hamiltonian path problem. One possible Hamiltonian cycle through every vertex of a dodecahedron is shown in red – like all platonic solids, the dodecahedron is Hamiltonian. Generate all possible configurations of vertices and print a configuration that satisfies the given constraints. There will be n! (n factorial) configurations.

PrepKit 概览

本概览由 PrepKit 编辑根据源代码仓库撰写并审核,并非资源本身的文字。

适合人群
来源未说明适用级别
形式
参考资料

涵盖内容

  • 定义,以十二面体为例
  • 尝试全部 n! 种顶点排列的伪代码
  • 从顶点 0 出发、用相邻且未使用的顶点逐步扩展路径的回溯法

使用建议

这是 PrepKit 的学习建议,并非来源的说法。

在邻接矩阵上实现回溯版本,并在一个小图上比较实际探索的部分路径数与 n! 种排列数。

范围与局限

回溯部分只有一段文字,没有伪代码或复杂度,也没有提到 NP 完全性。

获取方式与形式

GitHub 上采用 MIT 许可的 trekhleb/javascript-algorithms 仓库中的免费英文 README。

PrepKit 于 2026年10月2日 审核。 资源来源提交: 85293e3e2b88

本概览的依据
  • src/algorithms/graph/hamiltonian-cycle/README.md

收录此条目的页面

订阅 PrepKit 通讯

可选。使用 PrepKit 并不需要订阅。

我们如何处理你的邮箱