Hamiltonian Cycles in Graphs: Algorithm and Example, Study notes of Computer Science

Hamiltonian cycles in graphs, their significance, and an algorithm to find them. An example of constructing a complete graph and finding a hamiltonian cycle using chvátal's algorithm. Students of computer science and mathematics may find this document useful for understanding graph theory concepts.

Typology: Study notes

Pre 2010

Uploaded on 02/25/2010

koofers-user-vtd
koofers-user-vtd 🇺🇸

5

(1)

10 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
COP 3503 – Computer Science II – CLASS NOTES - DAY #26
Hamiltonian Graphs
A Hamiltonian cycle in a graph is a cycle that passes through all the vertices of the
graph. Recall that we mentioned this type of cycle when we were examining Euler
paths and Euler circuits. A graph is called a Hamiltonian graph if it includes at
least one Hamiltonian cycle. There is no formula which characterizes a
Hamiltonian graph as there was with an Euler graph. However, it should be
obvious that all complete graphs are Hamiltonian. The question is how to find a
Hamiltonian cycle in a graph. The answer lies in the following theorem:
Basically, this theorem says that some Hamiltonian graphs allow us to create
Hamiltonian graphs by eliminating some of the edges in the graph. The theorem
leads directly to an algorithm that first expands the original graph to a graph with
more edges in which finding a Hamiltonian cycle is easy (a complete graph) and
then manipulates the Hamiltonian cycle by adding some edges and removing other
edges so that eventually a Hamiltonian cycle is formed that includes the edges that
belong to the original graph. An algorithm that is based on this theorem was
developed by Chvátal in 1985. The algorithm is shown below:
HamiltonianCycle( graph G = V, E))
set lable of all edges to 0;
k = 1;
H = E;
GH = G;
while GH contains nonadjacent vertices v, u where degH(v) + degH(u) V
H = H {edge(vu)};
GH = (V, H);
label (edge(vu)) = k++;
if there exists a Hamiltonian cycle C
while (k = max{label(edge(pq)) : edge(pq)
C}) > 0
C = a cycle due to a crossover with each edge labeled by a number < k;
Consider the following example illustrating the Hamiltonian cycle problem:
Day 26 - 1
More Graph Problems
Theorem:
If edge(vu)
E, graph G
= (V, E
{edge(vu)}) edge(vu)}) is Hamiltonian, and
degree(v)+ degree(u)
V, then graph G = (V, E) is also Hamiltonian.
pf3
pf4
pf5

Partial preview of the text

Download Hamiltonian Cycles in Graphs: Algorithm and Example and more Study notes Computer Science in PDF only on Docsity!

COP 3503 – Computer Science II – CLASS NOTES - DAY # Hamiltonian Graphs A Hamiltonian cycle in a graph is a cycle that passes through all the vertices of the graph. Recall that we mentioned this type of cycle when we were examining Euler paths and Euler circuits. A graph is called a Hamiltonian graph if it includes at least one Hamiltonian cycle. There is no formula which characterizes a Hamiltonian graph as there was with an Euler graph. However, it should be obvious that all complete graphs are Hamiltonian. The question is how to find a Hamiltonian cycle in a graph. The answer lies in the following theorem: Basically, this theorem says that some Hamiltonian graphs allow us to create Hamiltonian graphs by eliminating some of the edges in the graph. The theorem leads directly to an algorithm that first expands the original graph to a graph with more edges in which finding a Hamiltonian cycle is easy (a complete graph) and then manipulates the Hamiltonian cycle by adding some edges and removing other edges so that eventually a Hamiltonian cycle is formed that includes the edges that belong to the original graph. An algorithm that is based on this theorem was developed by Chvátal in 1985. The algorithm is shown below: HamiltonianCycle( graph G = V, E)) set lable of all edges to 0; k = 1; H = E; GH = G; while GH contains nonadjacent vertices v, u where degH(v) + degH(u)  V H = H  { edge(vu) }; GH = (V, H); label (edge(vu)) = k++; if there exists a Hamiltonian cycle C while (k = max{ label(edge(pq)) : edge(pq)C}) > 0 C = a cycle due to a crossover with each edge labeled by a number < k ; Consider the following example illustrating the Hamiltonian cycle problem: More Graph Problems Theorem: If edge(vu)E, graph G^ ^ = (V, E{edge(vu)}) edge(vu)}) is Hamiltonian, and degree(v)+ degree(u)   V , then graph G = (V, E) is also Hamiltonian.

Initial graph 1 2 4 5 3 7 6 Complete Graph- H The complete graph shown above is constructed as follows: In each iteration, two nonadjacent vertices are connected with an edge it the total number of their neighbors is not less than the number of all vertices in the graph. First look at all the vertices not adjacent to vertex A. For vertex C , degH( A ) + degH( C ) = 3+3 = 6  V= 6, thus edge(AC) labeled with number 1is includede in H. Next vertex E is considered, and since the degree of A just increased by 1 when it acquired new neighbor vertex B , we have degH(A) + degH(E) = 4+2 = 6, edge(AE) labeled with 2 is included in H. The next vertex, for which new neighbors are attempted to be established, is B which is of degree 2. There are three non-adjacent vertices: D, E, and F with degrees 2, 2, and 3 respectively. Therefore, the sum of B’s degree and the degree of any of these three vertices does not reach 6 and thus no edge is included in H. In the next four iterations, new neighbors are attempted for vertices C, D, E, and F. For node C the only nonadjacent node is D with degree 3 so we have degH( C ) + degH( D ) = 4+3 = 7  V= 6 so edge(CD) labeled 3 is included in H). For node D the only nonadjacent node is B with degree 2 so we have degH( D ) A B C D E F A B C D E F

Modified Hamiltonian Cycle In this new modified cycle, the edge(BE) has the highest label with value 5, so the cycle is presented with the vertices of this edge at the extreme ends of the sequence: B, D, F, A, C, E. To find the crossover edges, the first pair of edges edge(BF) and edge(DE) , but the label of edge(BF) = 7 which is greater than the largest label of the current cycle, so the pair is rejected. The next pair is edge(AB) and edge(EF) , however, once again, the pair is unacceptable since the label on edge(EF) is 6. The next possibility is the pair edge(BC) and edge(AE) , which is acceptable since the highest label is 2. Thus, the new cycle B, C, E, A, F, D, B is formed. B, D, F, A, C, E B, D, F, A, C, E crossovers 4 Finally, in this latest cycle, a pair of crossover edges is found, edge(AB) and edge(DE) that are acceptable since labels on both edges are 0 and a new cycle is formed which finally includes only edges with labels of 0 and thus are edges which appeared in the original graph and the algorithm terminates with the following Hamiltonian cycle including only edges from G. A B C D E F

B, C, E, A, F, D B, C, E, A, F, D

crossovers The final Hamiltonian cycle is shown in the next diagram. Final Hamiltonian Cycle: B-A-F-D-E-C-B A B C D E F