GraphUtilities`
GraphUtilities`

HamiltonianCycles

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

HamiltonianCycles[g,n]

gives a list of n Hamiltonian cycles.

HamiltonianCycles[g]

gives a list of one Hamiltonian cycle.

更多信息和选项

  • HamiltonianCycles functionality is now available in the built-in Wolfram Language function FindHamiltonianCycle.
  • To use HamiltonianCycles, you first need to load the Graph Utilities Package using Needs["GraphUtilities`"].
  • HamiltonianCycles[g,n] returns an empty list if no Hamiltonian cycle exists.
  • HamiltonianCycles considers the input graph as undirected.
  • The complexity of the algorithm is such that finding all Hamiltonian cycles for a large graph can take an exponential amount of time.

范例

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

基本范例  (2)

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

HamiltonianCycles has been superseded by FindHamiltonianCycle:

Scope  (1)

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

This plots the graph and highlights the cycle in red:

This finds all Hamiltonian cycles:

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)

A graph that has a Hamiltonian cycle must be biconnected:

A graph that is biconnected does not necessarily have a Hamiltonian cycle:

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

文本

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

CMS

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

APA

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

BibTeX

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

BibLaTeX

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