Anda di halaman 1dari 31

Seven Bridges Problem

In this chapter we consider the following problem:


Suppose you are going to a newly built shopping mall. You want to visit
the whole shopping mall, and you probably do not want to have any
repetition, i.e., not to revisit any corridor. Is there a route which passes
every corridor of the shopping mall exactly once? People considered
problems like this in the very past.
(GCNU1026) Smart Decisions Chapter 1 1 / 27
Seven Bridges Problem
Example (Seven Bridges Problem)
Konigsberg was divided by rivers into four parts and these separated pieces
of land were connected by seven bridges. Citizens of Konigsberg asked: Is
there any walk passing through the city that crosses each bridge exactly
once? This is now known as the Seven Bridges Problem.
(GCNU1026) Smart Decisions Chapter 1 2 / 27
Seven Bridges Problem
To solve this problem we want to transform this into a mathematical
problem. Since we are asking a path which passes through each bridge,
and each bridge connects two places, the useful information is the relative
position between the places and bridges. Other information, such as the
length of the bridges, or the money I would have to pay for crossing the
bridge, are irrelevant for this problem. In the modeling process, we only
consider information that is relevant to the solution of the problem.
(GCNU1026) Smart Decisions Chapter 1 3 / 27
What is a graph?
The above picture is the modeling we have done. We transform a map
into a picture consisting of dots and lines which connect the dots. In
mathematics, we have the following denition.
Denition
A graph consists of
a collection of vertices, and
a collection of edges.
Each edge is connected to two vertices.
In the above denition, we did NOT require that the vertices connected by
an edge must be dierent. i.e., an edge can connect to a vertex to itself.
In this case we call the vertex and the edge connecting it a loop.
We follow the convention that vertices are labeled by capital letters and
edges are labeled by small letters.
(GCNU1026) Smart Decisions Chapter 1 4 / 27
What is a graph?
Returning to the problem of transforming a map into a graph. If we want
to transform the following map into a graph, how should we draw it?
Note that dierent people may come up with dierent graphs.
(GCNU1026) Smart Decisions Chapter 1 5 / 27
Same Graph?
For example, let say we transform the above map into these two graphs.
A
C
B
D
c d
g
e
f
a b
C
A
D
B
c
d
g
e
f
b
a
Should we consider these two graphs to be the same or dierent?
(GCNU1026) Smart Decisions Chapter 1 6 / 27
Topological Equivalence
Since we are only interested in the relative position between the
vertices and edges, we should consider the above graphs to be the
same graph.
In graph theory these graphs are said to be topologically equivalent.
We will not dene it rigourously, whose denition is far beyond this
course.
(GCNU1026) Smart Decisions Chapter 1 7 / 27
Walk
Denition
A walk in a graph is a sequence of connected edges.
A
C
B
D
c d
g
e
f
a b
We denote a walk by the label of the edges. Consider walks which start at
C and ends at B. There are many such walks. For example, ca is such a
walk. cb is another walk. One of the complicated walk from C to B is
cdgf.
(GCNU1026) Smart Decisions Chapter 1 8 / 27
Tour
Denition
A tour in a graph is a sequence of connected edges starting vertex and
end vertex are the same.
By denition, a tour is a walk, while a walk is not necessarily a tour.
A
C
B
D
c d
g
e
f
a b
For example, cd and dc are tours starting and ending at vertex C. You can
also say they are tours starting and ending at A. If you want to avoid
confusion, you need to specify the starting vertex.
(GCNU1026) Smart Decisions Chapter 1 9 / 27
Euler Walk
A
C
B
D
c d
g
e
f
a b
Return to the Seven Bridges Problem. Recall that we want to nd a walk
which passes through every edge exactly once. In mathematics, we call
such a walk an Euler walk.
(GCNU1026) Smart Decisions Chapter 1 10 / 27
Euler Tour
If we further require the starting vertex and the end vertex of the
Euler walk to be the same, then it is called an Euler tour. Thus an
Euler tour is a tour which passes through every edge exactly once.
Euler, one of the greatest mathematicians, proved that there is no
Euler walk in Konigsberg. It means that there is no solution to the
Seven Bridges Problem. Since Euler tour is a special case of Euler
walk, we see that there is no Euler tour in Konigsberg either. How did
he prove it? To describe this we need more concepts in graph theory.
(GCNU1026) Smart Decisions Chapter 1 11 / 27
Degree
Denition
Given a graph, the degree of a vertex is the number of edges connecting
to the vertex.
A
C
B
D
c d
g
e
f
a b
We denote the degree of a vertex A by deg(A). For example, deg(C) = 3,
deg(A) = 5, deg(B) = 3 and deg(D) = 3.
(GCNU1026) Smart Decisions Chapter 1 12 / 27
A graph with Euler Walk
There are theorems which give equivalent statements for the existence of
Euler walks and Euler tours. i.e., if a graph satises certain conditions,
then it must have an Euler walk (or tour), AND if the graph has an Euler
walk, it must satises certain condition. Symbolically this can be written
as
A graph has an Euler walk (tour) the graph satises some conditions.
If there are such conditions, we regard the statements A graph has an
Euler walk (tour) and A graph satises some conditions to be
equivalent.
(GCNU1026) Smart Decisions Chapter 1 13 / 27
Necessary and Sucient
Before we present the theorems, we have to distinguish which
statements are equivalent and which are not. Moreover, a statement
could be a consequence of another statement, but not vice versa.
For example, consider the statements My mother is a woman and
A woman is my mother. The rst statement is always true, while
the second statement is not.
Since not every woman is my mother. Thus I can say If she is my
mother, then she is a woman. But I cannot say If someone is a
woman, then she is my mother. Thus the statements being a
woman and being my mother are not equivalent.
(GCNU1026) Smart Decisions Chapter 1 14 / 27
Necessary and Sucient
Knowing how to distinguish between equivalent and inequivalent
statements are very useful when you read books in mathematics, and
in particular, in this course.
Consider the above example again. A human being is a woman is a
necessary condition for her to be my mother. However, this
condition does not guarantee that she is my mother. i.e., not a
sucient condition.
(GCNU1026) Smart Decisions Chapter 1 15 / 27
Necessary and Sucient
Consider the following example, which is more mathematical.
The sum of all the internal angles of a square is 360 degree. However, if
the sum of all the internal angles of a polygon is 360, we cannot say it
must be a square.
For example, the sum of all the internal angles of a rectangle is also 360
degree. Note that for a trapezium, its sum of all the internal angles is 360
too. Thus the statement sum of all internal angle of a polygon = 360 is
a necessary condition for that polygon to be a square, but not a sucient
condition. i.e., we cannot say if the sum of all internal angle of a polygon
is 360, then it must be a square. It could be a rectangle or a trapezium.
(GCNU1026) Smart Decisions Chapter 1 16 / 27
A graph with Euler Walk/Tour
Now we want to determine a condition for which an Euler walk must exist.
Besides the starting and the end vertex, the degree of every other vertex
must be even! Why?
It is because if you go to that vertex, you have to go out (note that this
vertex is not the starting one and the end one). Thus there must be two
distinct edges. In the denition of Euler walk we are allowed to go to the
same vertex again. Thus if you are entering in same vertex with an unused
edge, you have to leave that vertex with another unused edge. Thus the
degree of that vertex is always even. For convenience we make the
following denition.
Denition
If the degree of a vertex is an even integer, then we call it an even vertex.
If the degree of a vertex is an odd integer, then we call it an odd vertex.
(GCNU1026) Smart Decisions Chapter 1 17 / 27
A graph with Euler Walk/Tour
Now we want to determine a condition for which an Euler walk must exist.
Besides the starting and the end vertex, the degree of every other vertex
must be even! Why?
It is because if you go to that vertex, you have to go out (note that this
vertex is not the starting one and the end one). Thus there must be two
distinct edges. In the denition of Euler walk we are allowed to go to the
same vertex again. Thus if you are entering in same vertex with an unused
edge, you have to leave that vertex with another unused edge. Thus the
degree of that vertex is always even. For convenience we make the
following denition.
Denition
If the degree of a vertex is an even integer, then we call it an even vertex.
If the degree of a vertex is an odd integer, then we call it an odd vertex.
(GCNU1026) Smart Decisions Chapter 1 17 / 27
A graph with Euler Walk/Tour
Thus we see that all the vertices are even, besides the starting and end
vertices, is a necessary condition for a graph to have an Euler walk.
Equivalently, if a graph has at most two odd vertices, then it has an Euler
walk. It turns out that it is also a sucient condition.
Theorem (Euler Walk)
A connected graph has an Euler walk if and only if it has at most two odd
vertices.
if and only if means the statements A connected graph has an Euler
walk and that connected graph has at most two odd vertices are
equivalent.
Theorem (Euler Tour)
A connected graph has an Euler tour if and only if all the vertices are even.
(GCNU1026) Smart Decisions Chapter 1 18 / 27
A graph with Euler Walk/Tour
Thus we see that all the vertices are even, besides the starting and end
vertices, is a necessary condition for a graph to have an Euler walk.
Equivalently, if a graph has at most two odd vertices, then it has an Euler
walk. It turns out that it is also a sucient condition.
Theorem (Euler Walk)
A connected graph has an Euler walk if and only if it has at most two odd
vertices.
if and only if means the statements A connected graph has an Euler
walk and that connected graph has at most two odd vertices are
equivalent.
Theorem (Euler Tour)
A connected graph has an Euler tour if and only if all the vertices are even.
(GCNU1026) Smart Decisions Chapter 1 18 / 27
Hierholzers Algorithm
Now suppose we know that a given graph has an Euler walk (or an Euler
tour), how to actually nd such an Euler walk (Euler tour)? For a graph
which has few vertices and edges, I will nd it by trail and error. For a
graph which has many vertices and edges, trial and error is a kind of waste
of time.
There is an algorithm, called the Hierholzers Algorithm, which provides
a systematic way to nd an Euler walk of a graph with exactly two odd
vertices.
(GCNU1026) Smart Decisions Chapter 1 19 / 27
Hierholzers Algorithm
Idea of the Hierholzers Algorithm.
1
Start from an odd vertex (A) and nd a walk without repeated edges
to another odd vertex (B).
2
If the current (A, B)-walk does not contain all edges, then choose a
vertex (C) from the current (A, B)-walk that still connects to some
unused edges. Find and then add a tour, which starts and ends at
(C), consisting of the unused edges only to the original walk to get a
new and longer walk.
3
Repeat Step 2 until there is no more unused edges.
Lets look at some examples.
(GCNU1026) Smart Decisions Chapter 1 20 / 27
Fleurys algorithm
We have another algorithm, called the Fleurys algorithm, which works for
both the Euler walk and Euler tour.
Idea of the Fleurys algorithm.
1
Choose an odd vertex (if the graph has none, then start with any
vertex).
2
From the current vertex, move across an edge whose deletion would
not disconnect the graph, unless we have no choice.
3
Delete that edge (if there are some vertices singled out, then also
delete them).
4
If there are no edges left, then stop, else go to Step 2.
(GCNU1026) Smart Decisions Chapter 1 21 / 27
Summary
To summarize what we have learned so far, for a given connected graph,
more than two odd vertices no Euler walk and no Euler tour,
exactly two odd vertices has an Euler walk but no Euler tour,
all vertices are even both Euler walk and Euler tour.
What about the case of having exactly one odd vertex?
We claim that a (nite) graph cannot have exactly one odd vertex.
Indeed, we claim the following stronger result.
(GCNU1026) Smart Decisions Chapter 1 22 / 27
Summary
To summarize what we have learned so far, for a given connected graph,
more than two odd vertices no Euler walk and no Euler tour,
exactly two odd vertices has an Euler walk but no Euler tour,
all vertices are even both Euler walk and Euler tour.
What about the case of having exactly one odd vertex?
We claim that a (nite) graph cannot have exactly one odd vertex.
Indeed, we claim the following stronger result.
(GCNU1026) Smart Decisions Chapter 1 22 / 27
Handshaking Theorem
Theorem (Handshaking Theorem)
Every nite graph has an even number of odd vertices.
For simplicity we assume in the above theorem that the graph does not
contain a loop. This theorem is true for graphs which contain loops, but
the argument is slightly more complicated.
This theorem say that every nite graph cannot have 1 odd vertex, or 3
odd vertices, or 5 odd vertices, etc. This is why we call it a stronger result.
We will explain why we call this theorem the handshaking theorem.
(GCNU1026) Smart Decisions Chapter 1 23 / 27
Handshaking Theorem
We show why this handshaking theorem is true.
First of all, note that we have the following fact:

v
deg(v) = 2e,
where e is the number of edges of a graph. The left-hand side is the sum
of degrees of all the vertices v of a graph. We will simply take this fact as
granted and not prove it. We can rewrite this identity as

odd vertices v
deg(v) +

even vertices v
deg(v) = 2e.
Here we group all the odd vertices and all the even vertices into two sums.
Note that

even vertices v
deg(v) is always an even integer as it is the sum of
even integers.
(GCNU1026) Smart Decisions Chapter 1 24 / 27
Handshaking Theorem
Then we rewrite the identity as

odd vertices v
deg(v) = 2e

even vertices v
deg(v).
Note that the right-hand side is an even integer. Now, if you look at the
left-hand side, when is a sum of odd integers even? A sum of odd integers
is even only if there are even number of odd integers. In our case, it means
there are even number of odd vertices, which proves what we want.
(GCNU1026) Smart Decisions Chapter 1 25 / 27
Handshaking Theorem
What does this theorem have to do with handshaking?
Lets imagine you are in the Ocamp, and you shake hands with others.
Lets count the number of handshakes of all the people in the Ocamp.
When you shake hands with others, you count it once. The person who
shakes hands with you also counts once. Thus whenever there is a
handshake in Ocamp, the number of handshakes is 2, not 1. Thus the
number of total handshakes must be even. Indeed, the number of total
handshakes is twice of number of hands!
(GCNU1026) Smart Decisions Chapter 1 26 / 27
Handshaking Theorem
What does this theorem have to do with handshaking?
Lets imagine you are in the Ocamp, and you shake hands with others.
Lets count the number of handshakes of all the people in the Ocamp.
When you shake hands with others, you count it once. The person who
shakes hands with you also counts once. Thus whenever there is a
handshake in Ocamp, the number of handshakes is 2, not 1. Thus the
number of total handshakes must be even. Indeed, the number of total
handshakes is twice of number of hands!
(GCNU1026) Smart Decisions Chapter 1 26 / 27
Handshaking Theorem
If you think of
people vertices,
hands edges,
shaking hands with people an edge connects a vertex,
number of handshakes degree of vertices,
then the number of the total handshakes the total degree of all the
vertices are even. That is

v
deg(v) = 2e,
where we recall that the right-hand side represents twice the number of
edges.
(GCNU1026) Smart Decisions Chapter 1 27 / 27

Anda mungkin juga menyukai