Transcript Slide 1

An Euler Circuit is a cycle of an undirected graph, that traverses every
edge of the graph exactly once, and ends at the same node from
which it began.
Euler's Theorem: A connected graph G possesses an Euler circuit if and
only if G does not contain any nodes of odd degree.
Proof of Euler's theorem: Assume that G has zero nodes of odd
degree. It can then be shown that this is a necessary and a sufficient
condition for an Euler circuit to exist.
Part 1: It is necessary because any Euler circuit drawn on the graph
must always enter a node through some edge and leave through
another and all edges on the graph must be used exactly once.
Thus, an even number of incident edges is required for every
node on the graph.
Proof of Euler's theorem Part 2:
Sufficiency, on the other hand, can be shown through the following tour
construction argument. We begin at some initial node k0 and draw a
circuit through G (thus eventually returning to k0). Let this circuit be
denoted C0. If C0 happens to be an Euler circuit, this is fine; we
stop. If C0 is not an Euler circuit, then if we remove from G all edges
used by circuit C0, there must be some edges left over. Moreover, at
least two of these edges must be incident on some node k1 through
which circuit C0 has passed. This must be so since, by assumption,
G is, first, connected and, second, all its nodes are of even degree
(and C0 has only used up an even number of edges which are
incident on k1). Thus, it is possible to draw another circuit C1
originating and terminating at k1, which uses only edges of G', the
graph left after we eliminate the edges of C0 from G.
This procedure may now be continued until eventually, say after the nth
step, there will be no edges left uncovered. At that time, an Euler
circuit will also have been obtained which will be a combination of
circuits C0, C1, C2, . . ., Cn.
Euler's theorem is a proof by construction.
However, the algorithm could be O(E2) or O(E log E)
where E is the number of edges in the graph.
Note: both of these are O(E2):
for i = 1 to n
{ for k = 1 to n
{
}
}
for i = 1 to n { }
for i = 1 to n { }
.
. (linear function of n times)
.
for i = 1 to n { }
Fleury's Algorithm: O(E)?
1. Pick any vertex to start.
2. From that vertex pick an edge to traverse, considering following
rule: never cross a bridge of the reduced graph unless there is no
other choice.
3. Darken that edge, as a reminder that you can't traverse it again.
4. Travel that edge, coming to the next vertex.
5. Repeat 2-4 until all edges have been traversed, and you are back at
the starting vertex.
By reduced graph we mean the original graph minus the darkened
(already used) edges.
A bridge of a graph G is an edge whose deletion increases the number
of components of G.
Fleury's Algorithm in Action
Pick any vertex (e.g. F)
Take F to C (arbitrary)
Take C to D (arbitrary)
Take D to A (arbitrary)
A bridge is not a local
property (i.e. if edge EF
existed then AB would not
be a bridge).
How can we recognize a bridge efficiently?
Take A to C.
Can't go to B: that edge is a
bridge of the reduced graph,
and there are two other choices.
In the original graph, AB was not a bridge.
Can we preprocess the graph in O(E) time
identifying bridges and building a structure that
can be updated in constant time with each
reduction?
Scrub Tile Puzzle
A Hamiltonian Cycle
Puzzle Applet
Given 10 equally sized index cards each with one of the following words:
HEN, HUT, WIT, SAW, CAR, CUB, MOB, DIM, RED, SON.
Arrange the cards in a rectangular closed chain such that any two
adjacent words must share a common letter.
The above may serve to demonstrate a possible arrangement. However, the
words SON and RED, although adjacent, do not have a letter in common.
Therefore, it's not a valid configuration.
Repeat the same problem with the cards SON and HUT replaced by SUN and
HOT.
Scrub Tile Puzzle
Of the two variants of the puzzle, the second is solvable, the first is
not.
The two variants are represented by different graphs. A solution to
the puzzle constitutes a Hamiltonian circuit on its graph. The first
of the two is the famous Petersen graph that is known not to house
any Hamiltonian circuits.
Dodecahedral Graph
Is it Hamiltonian? If so, find the Hamiltonian Cycle
A
F
G
O
E
N
H
V
Z
W
M
P
Y
X
K
L
D
J
C
B
Knight's Tour Problem
The "Knight's Tour" is a sequence of moves done by a
knight on a chessboard. The knight is placed on an
empty chessboard and, following the rules of chess,
must visit each square exactly once. There are several
billion solutions to the problem, of which about
122,000,000 have the knight finishing on a square which
is just a move away from the starting square. Such a tour
is described as “closed”.
The Knight's Tour problem is an instance of the more
general Hamiltonian path problem in graph theory. The
problem of getting a closed Knight's Tour is similarly an
instance of the Hamiltonian cycle problem.
Find a Closed Knight's Tour
State as Hamiltonian Path Problem
For a given n value, find an arrangement of the
first n natural values such that, at the same time:
• The sum of every two adjacent numbers is a
prime.
• The sum of every two adjacent squares is a
prime.
Find such a sequence for n = 10.