GraphTheory[IsHamiltonian]
|
Calling Sequence
|
|
IsHamiltonian(G)
IsHamiltonian(G, C)
|
|
Parameters
|
|
G
|
-
|
unweighted graph
|
C
|
-
|
(optional) name
|
|
|
|
|
Description
|
|
•
|
A graph G on n vertices is Hamiltonian if there exists a cycle in G containing each of the n vertices once.
|
•
|
The IsHamiltonian(G) function returns true if the graph is Hamiltonian and false otherwise. If G is Hamiltonian and a name C is specified as a second argument, then C is assigned a list of vertices of a Hamiltonian cycle of the graph starting and ending with the first vertex in G. For example, if the graph G is the triangle graph created with Graph({{1,2},{1,3},{2,3}}), the cycle is output as .
|
•
|
The algorithm works for directed graphs and it ignores the edge weights of weighted graphs.
|
|
|
Examples
|
|
>
|
|
>
|
|
>
|
|
| (1) |
>
|
|
| (2) |
>
|
|
| (3) |
>
|
|
| (4) |
>
|
|
| (5) |
>
|
|
>
|
|
| (6) |
>
|
|
| (7) |
>
|
|
| (8) |
>
|
|
>
|
|
>
|
|
| (9) |
>
|
|
| (10) |
>
|
|
| (11) |
>
|
|
IsHamiltonian: "graph satisfies MinimumDegree(G) >= NumberOfVertices(G)/2 ==> it is hamiltonian"
| |
| (12) |
>
|
|
| (13) |
>
|
|
IsHamiltonian: "graph satisfies IndependenceNumber(G) > NumberOfVertices(G)/2 ==> it's not hamiltonian"
| |
| (14) |
|
|
Download Help Document
Was this information helpful?