GraphUtilities`
GraphUtilities`

FindHamiltonianCycle

As of Version 10, all the functionality of the GraphUtilities package is built into the Wolfram System. »

FindHamiltonianCycle[g]

attempts to find a Hamiltonian cycle.

更多信息和选项

  • FindHamiltonianCycle functionality is now available in the built-in Wolfram Language function FindHamiltonianCycle.
  • To use FindHamiltonianCycle, you first need to load the Graph Utilities Package using Needs["GraphUtilities`"].
  • FindHamiltonianCycle[g] returns an empty list if no Hamiltonian cycle is found.
  • FindHamiltonianCycle considers the input graph as undirected.
  • FindHamiltonianCycle uses heuristic algorithms to find a Hamiltonian cycle; therefore, there is no guarantee that a Hamiltonian cycle will be found even if one exists.

范例

打开所有单元关闭所有单元

基本范例  (2)

This defines a small graph and finds a Hamiltonian cycle of the graph:

This function has been superseded by FindHamiltonianCycle in the Wolfram System:

Options  (2)

MaxIterations  (1)

This limits the maximum number of iterations to try to find a Hamiltonian cycle:

RandomSeed  (1)

This specifies a random seed different from the default to try to find a Hamiltonian cycle:

Applications  (1)

This finds all possible Hamiltonian cycles in the graph consisting of bordering countries in South America:

This shows the first of these two cycles; the second is just a reversal of the first:

Properties & Relations  (1)

FindHamiltonianCycle uses heuristic algorithms. Unlike HamiltonianCycles, it is not guaranteed to find a Hamiltonian cycle even when one exists. But for large graphs, FindHamiltonianCycle can sometimes be faster at finding one cycle.

This defines a graph of 500 vertices, and uses these two functions to find a Hamiltonian cycle:

Possible Issues  (1)

FindHamiltonianCycle uses heuristic algorithms, which are not guaranteed to find a Hamiltonian cycle even when one exists:

Wolfram Research (2007),FindHamiltonianCycle,Wolfram 语言函数,https://reference.wolfram.com/language/GraphUtilities/ref/FindHamiltonianCycle.html.

文本

Wolfram Research (2007),FindHamiltonianCycle,Wolfram 语言函数,https://reference.wolfram.com/language/GraphUtilities/ref/FindHamiltonianCycle.html.

CMS

Wolfram 语言. 2007. "FindHamiltonianCycle." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/GraphUtilities/ref/FindHamiltonianCycle.html.

APA

Wolfram 语言. (2007). FindHamiltonianCycle. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/GraphUtilities/ref/FindHamiltonianCycle.html 年

BibTeX

@misc{reference.wolfram_2024_findhamiltoniancycle, author="Wolfram Research", title="{FindHamiltonianCycle}", year="2007", howpublished="\url{https://reference.wolfram.com/language/GraphUtilities/ref/FindHamiltonianCycle.html}", note=[Accessed: 18-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_findhamiltoniancycle, organization={Wolfram Research}, title={FindHamiltonianCycle}, year={2007}, url={https://reference.wolfram.com/language/GraphUtilities/ref/FindHamiltonianCycle.html}, note=[Accessed: 18-November-2024 ]}