You are on page 1of 16

HAMILTONIAN PATHS &

CIRCUITS
Greedy
Hamiltonian Circuit Algorithm
Hamiltonian
Path
Edge-
Dirac's Theorem Picking
algorithm
Hamiltonian Weighted Graphs
• Hamiltonian Path - a path that visit each
vertex of the graph exactly once
• Hamiltonian Circuit - a path that uses its
vertex of a graph exactly at once and
returns to the starting vertex
• Hamiltonian - A graph that contains a
Hamiltonian circuit
In Euler circuits, closed paths used every edge exactly
once, possibly visiting a vertex more than once. On the
contrary, in Hamiltonian circuits, paths visit each vertex
exactly once, possibly not passing through some of the
edges. But unlike the Euler circuit, where the Eulerian
Graph Theorem is used to determine whether it contains
an Euler circuit or not, there is no straightforward
criterion to determine whether or not a Hamiltonian
circuit exists in a graph.
DIRAC'S THEOREM
Consider a connected graph with at least
three vertices and no multiple edges. Let n
be the number of vertices in the graph. If
every vertex has a degree of at least n/2,
then the graph must be Hamiltonian
Example:

• Determine whether the A B C

graph on the right side is


E
Hamiltonian or not. If it
is, find a Hamiltonian
circuit. If it is not, explain
G F D
why.
SOLUTION:
• There are seven vertices, hence
n/2 = 3.5. Since vertex A is of
degree 2, Dirac's theorem does
not apply here. But it does not
necessarily follow that the graph
is not Hamiltonian. In fact, it is.
Consider the path
A-B-C-D-E-F-G-A. This path
visits each vertex only once in
the graph and returns to its
starting point, therefore it is
Hamiltonian.
Seoul
EXAMPLE 6. An application of Hamiltonian Circuits

The graph shows the Tokyo

available flights of a Hong Kong


popular airline. An edge Taipei
between two vertices
indicates that there is a Bangkok Macau

direct flight between the Manila


two cities. Apply Dirac's Ho Chi Minh
Theorem to verify that the
graph is Hamiltonian. Then Kuala Lumpur
find a Hamiltonian circuit.
Singapore
Solution: Seoul Seoul

There are ten vertices in the graph, so n=10 and n/2=5. Now,
vertex Manila has nine edges, TokyoTokyo five, Seoul five, Taipei Tokyo

six, Hong Kong seven, Macau nine,


Hong Kong HongBangkok
Kong six, Ho Chi
Minh five, Kuala Lumpur Taipei five, and Singapore Taipei five. Using
Dirac's Theorem, if each vertex
Bangkok Bangkokhas a degree of at least n/2=5,

then the graph is Hamiltonian. This means


Macau Macau
that the graph
contains
Ho Chi Minh
a circuit that visits
Manila
each vertex
Ho Chi Minh
and returns to its
Manila

starting point without visiting a vertex more than once. By


trial and error, one Hamiltonian circuit is Manila - Tokyo -
Kuala Lumpur Kuala Lumpur
Seoul - Taipei - Hong Kong - Macau - Bangok - Ho Chi
Minh - Kuala Lumpur Singapore - Singapore - Manila. Singapore
Seoul
In example 6, there is a number of different paths which are
Hamiltonian. For example, Manila - Tokyo - SeoulTokyo - Hong Kong -
Weighted Graphs
Macau - Bangkok - Ho Chi Minh - Kuala
Hong Kong
Lumpur - Singapore
Taipei

- Taipei - Manila is another Hamiltonian circuit that represents a


A weighted graph is a
sequence of flights that visits each city and returns to the starting
graph in which each edge is
Bangkok
city without visiting any city twice. Macau
Although generally the lengths
of the edges do not matter in a graph, there Manila is now concern over
associated
the route that minimizes with value,
the distance travelled. In other words,
Ho Chi Minh

called weight.
there is a need to know which of these Hamiltonian routes is the
cheapest. Hence, it isKuala butLumpur
important that one focuses in the
distances between two cities. This distances can be represented
using weighted graphs. Singapore
Draw a graph thatFind two different

Cagayan de
Example 7. An application

Palawan
Manila
represents this routes that visit each of

Ozamis
Davao
Cebu

Oro
of Hamiltonian Circuits
information where
The table on the right
each the places and return to
vertex represents
lists down the distances a city its
Manila
starting
- 355
point
485 589
without
358 477

and
(miles)an between
edge connects
the Cebuvisiting
355 - any137 city
240 354twice.
140

two
citiesvertices
having ifdirect
the twoCompare
Cagayan
de Oro485 137 - the
118 414 total
64

cities
routes have a direct
as well as theflight number
Davao 589 240 118 of - 495 miles
133
corresponding
with distances Palawa
their corresponding travelled by each of
358 354 414 495 - 363
between them. n
weights. these routes.
Ozamis 477 148 64 133 363 -
Solution:
A. The graph along with the weight of the edges is shown B. One Hamiltonian circuit is
below
Manila Cebu Ozamis - Cagayan de Oro- Cebu -
355 Palawan - Manila - Davao then
148 back to Ozamis. The total distance
travelled is 64 + 137 + 354 + 358 +
477 354
589+ 133 = 1635 miles. Another
455 node route is Ozamis - Davao -
589 358
Cagayan de Oro - Palawan- Cebu
Ozamis 363 Palawan
- Manila then back to Ozamis. This
64
240 circuit has a total distance of 133 +
133 414 118 + 414 + 354 + 355 + 477 =
137 1851 miles. Obviously, the first
495 node route is shorter than the
118 second.
Dava Cagayan de Oro
o
In
Theexample 7, we computed two Hamiltonian routes. But these results do
Greedy Algorithm
not guarantee that one of them is the shortest distance travelled. From
the 1.solution
Choose in a vertex
example to start
7, at,is and then travel
Ozamiz all along
- Cagayan de the
Oroconnected
- Cebu -
edge that
Palawan has the- smallest
- Manila Davao -weight.
Ozamis(Ifthetwoshortest
or moreroute?
edges have
Theretheis no
same weight,
guarantee. pickisany
If this the one.)
case, how can the shortest route be determined
after visiting all the cities exactly once and going back to the origin city?
One2.method
After arriving at the
is to list downnextallvertext, travel along
Hamiltonian an edge
circuits, of the
compute the total
smallest and
weight, weight that connects
choose to a vertex
the smallest not yetUnfortunately,
total weight. visited. Continue
this is
this process
tedious until you
specially when have
thevisited
numberall vertices.
of possible circuits is too large.
However, there are two algorithns, the greedy algorithm and the edge-
3. Return
picking to the starting
algorithm, that canvertex.
help in finding a good solution. Note that
these both algorithms apply only to complete graphs.
Solution using the Greedy Algorithm:
To find the least route that Aaron can take, one can
find a Hamiltonian circuit using the greedy
Example
algorithm. By 8:trial and error, one Hamiltonian Aaron
Aaron, Belle, house Carol, TAKE 13 NOTE:
Carol
circuit is from Aaron's - Belle's house -
Carol's
Donna.houseEric,- and
Donna's house
Fe are - Eric's
best of house - Fe's The7 Greedy
house and back to Aaron's. The total weight of the
friends. The following figure 12
Algorithm 8
circuit is 1 + 2+ 3 + 9 + 6 + 12 = 33. But there are
shows the distances attempts to give
other Hamiltonian circuits from(inAaron's house. 4

kilometers) from a friend's Fe


Consider the Hamiltonian circuit from Aaron's
1
a circuit
6
5
a Eric
house
place - Eric's house - Fe's
to another. If house
Aaron- Carol's house 14
- minimal total
Donna's house - Belle's house and back to Aaron's. 2
wants weight, although
The totalto visitof this
weight eachcircuit
of ishis
5 + 6 + 7 + 3 11+ 9
friends'
10 + 1 = houses exactly
32. Ironically, this once,
circuit has a weight it does 3 not
lesser
what than
is thetheshortest
weight ofroute
the circuit
that derived using always
15
succeed.
the greedy algorithm. thus, the greedy algorithm 10
he must take?
only attempts to give a circuit of minimal total Belle Donna

weight, although it does not always succed.


Solution using the edge-picking algorithm
The Edge-Picking Algorithm
To find the route with the least distance that Aaron
Aaron can take, one can find a
Carol
Hamiltonian circuit using the edge-picking algorithm. First,13 mark the line
1. Mark the edge of the smallest
segment from Aaron's house to Belle's house, of weight 1. Next, 7 mark the
weight in the graph. (If two or more edges
segment from Belle's house to Carol's house, of weight 2, followed by Carol's
have the same weight, pick any one.) 12 8
to Donna's house, of weight 3, followed by Eric's to Fe's house, of weight 6.
2. Mark the edge of the next smallest
Take note that we cannot mark the segment from Eric's4 house to Aaron's
weight in the graph, as long as it does not 1 5
because it can complete a circuit. Also, we cannot mark the segment from
complete a circuit and does not add Fe a 6
Carol's to Fe's house because it can make the third mark edge on a vertex.
third marked edge to a single vertex. 14
Finally to complete the circuit, we mark the line segment from 2 Fe's house back
3. Continue this process until you can
to Aaron's. The final Hamiltonian circuit, of total11weight 1 + 2 + 3 + 6 + 9 + 12 9
no longer mark any edges. Then mark the
= 33, is Aaron's house - Belle's house - Carol's house - Donna's house 3 -
final edge that completes the Hamiltonian
Eric's house - Fe's house and back to Aaron's. A Hamiltonian 15 circuit forms
circuit.
a complete loop so we can actually start from any of the vertices. 10 It is important
Belle the circuit.
to note that we can reverse direction in which we follow Donna
Graph Coloring
Planar Graph
A planar graph is a graph that can be drawn so that no edges
intersect each other (except at vertices).
The Chromatic Number of a Graph
The minimum number of colors needed
to color a graph so that no edge connects
vertices of the same color is called th
chromatic number.

Planar Non-planar

You might also like