Lecture 5 part 2 - PowerPoint PPT Presentation

1 / 56
About This Presentation
Title:

Lecture 5 part 2

Description:

2. Euler Circuit. Leonhard Euler (pronounced OIL-er) 1707-1783, Swiss Mathematician ' ... Since by definition, 'An Euler circuit for G is a circuit that ... – PowerPoint PPT presentation

Number of Views:53
Avg rating:3.0/5.0
Slides: 57
Provided by: GohAi5
Category:
Tags: euler | lecture | leonhard | part

less

Transcript and Presenter's Notes

Title: Lecture 5 part 2


1
Lecture 5 (part 2)
  • Graphs II
  • Euler and Hamiltonian Path / Circuit
  • Reading Epp Chp 11.2, 11.3

2
2. Euler Circuit
Leonhard Euler (pronounced OIL-er) 1707-1783,
Swiss Mathematician Is it possible for a person
to take a walk around the town of Königsberg,
starting and ending at the same location and
crossing each of the seven bridges exactly once?
3
2.1 Euler Circuit (Definition)
  • Definition Let G(V,E) be a graph (simple or
    multigraph).
  • An Euler Circuit for G is a simple circuit that
    contains every edge in E.
  • Implications
  • simple circuit edges must be distinct
  • At most 1 traversal of each edge.
  • every edge in E
  • At least 1 traversal of each edge.

4
2.2 Euler Circuit Theorem
  • (Euler Circuit Theorem)
  • Let G(V,E) be a graph.
  • G has an Euler circuit iff G is connected AND
    every vertex of G has even degree.
  • Proof Strategy
  • () Assume G has an Euler Circuit
  • Prove (1) G is connected
  • (2) "vÎV, deg(v) 2k (for some k)
  • () Assume G is connected and
  • "vÎV, deg(v) 2k (for some k)
  • Prove G has an Euler Circuit

5
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume G(V,E) has an Euler circuit.
    Show (1) G is connected, (2) ("vÎV, deg(v) 2k)
  • To Prove G is connected. (Defn of connected?)
  • Since G has an Euler Circuit, then let
  • v0 e1 v1 e2 v2 en-1 vn-1 en v0
  • be the Euler Circuit.
  • Pick any 2 vertices x, y in V.
  • Now, x must be some vi and y must be some vj in
    the Euler circuit. (Why? Since by definition,
    An Euler circuit for G is a circuit that
    contains EVERY VERTEX in V)
  • If i j then we have a path from x vi ei1
    vi1 ej vj y
  • If i gt j then we have a path from x vi ei vi-1
    ej1 vj y
  • Therefore there is a path from x to y in V.
  • Therefore G is connected (by definition of
    connected graph).

6
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume G(V,E) has an Euler circuit.
    Show (1) G is connected, (2) ("vÎV, deg(v) 2k)
  • Now, we prove (2)
  • To show that any vertex has an even degree.
  • Pick any vertex v in V.
  • Since G has an Euler circuit, then that circuit
    must pass through v (by defn of Euler circuit
    circuit that contains EVERY VERTEX in V)
  • Look at the circuit from the viewpoint of v as
    the starting vertex.
  • Each time v is exited through the use of one
    edge, it must be returned to by the use of
    another edge.

7
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume G(V,E) has an Euler circuit.
    Show (1) G is connected, (2) ("vÎV, deg(v) 2k)

Each time v is exited through the use of one
edge, it must be returned to by the use of
another edge.
If v has some more edges incident on it, the
process repeats again (Why? Because Euler Circuit
traverses every edge in E).
8
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume G(V,E) has an Euler circuit.
    Show (1) G is connected, (2) ("vÎV, deg(v) 2k)

Each time v is exited through the use of one
edge, it must be returned to by the use of
another edge.
If v has some more edges incident on it, the
process repeats again (Why? Because Euler Circuit
traverses every edge in E).
9
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume G(V,E) has an Euler circuit.
    Show (1) G is connected, (2) ("vÎV, deg(v) 2k)

Each time v is exited through the use of one
edge, it must be returned to by the use of
another edge.
Edges on v occur in exit / entry pairs! Degree of
v must be a multiple of 2 gt EVEN!!!
10
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume (1) G is connected, (2)
    ("vÎV, deg(v) 2k). Show G(V,E) has () an
    Euler circuit.
  • Proof
  • The proof that there is () an Euler circuit,
    will be given by an ALGORITHM for finding the
    circuit.
  • We first present the algorithm.
  • We next show that the algorithm is correct.
  • (1) It will ALWAYS terminate and
  • (2) If it terminates, it will ALWAYS find the
    circuit.

11
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume (1) G is connected, (2)
    ("vÎV, deg(v) 2k). Show G(V,E) has () an
    Euler circuit.

Proof (The algorithm)
  • Step 1 Pick any vertex v ÎV as the starting
    vertex.
  • Step 2 Pick any sequence of adjacent vertices
    and edges starting and ending at v, and never
    repeating an edge. Let this circuit be C.

C v 1 2 3 v
12
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume (1) G is connected, (2)
    ("vÎV, deg(v) 2k). Show G(V,E) has () an
    Euler circuit.

Proof (The algorithm)
  • Step 3 Does C contain every edge and vertex of
    G?
  • If Yes, then stop and output C, which is an
    Euler circuit.
  • If No

1
2
v
3
C v 1 2 3 v
13
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume (1) G is connected, (2)
    ("vÎV, deg(v) 2k). Show G(V,E) has () an
    Euler circuit.

Proof (The algorithm)
  • Step 3a Remove the circuit C from G creating G.

4
1
5
2
v
G
6
3
C v 1 2 3 v
14
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume (1) G is connected, (2)
    ("vÎV, deg(v) 2k). Show G(V,E) has () an
    Euler circuit.

Proof (The algorithm)
  • Step 3a Remove the circuit C from G creating G.

4
1
5
G
6
3
C v 1 2 3 v
15
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume (1) G is connected, (2)
    ("vÎV, deg(v) 2k). Show G(V,E) has () an
    Euler circuit.

Proof (The algorithm)
  • Step 3b Pick any vertex u common to C and G

4
1
5
6
u
3
C v 1 2 3 v
16
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume (1) G is connected, (2)
    ("vÎV, deg(v) 2k). Show G(V,E) has () an
    Euler circuit.

Proof (The algorithm)
  • Step 3c Pick any sequence of adjacent vertices
    and edges of G, starting and ending at u, never
    repeating an edge, creating another circuit C.

4
1
5
6
u
3
C v 1 2 3 v
17
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume (1) G is connected, (2)
    ("vÎV, deg(v) 2k). Show G(V,E) has () an
    Euler circuit.

Proof (The algorithm)
  • Step 3c Pick any sequence of adjacent vertices
    and edges of G, starting and ending at u, never
    repeating an edge, creating another circuit C.

4
1
5
6
u
3
C v 1 2 3 v
C 3 6 5 4 1 3
18
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume (1) G is connected, (2)
    ("vÎV, deg(v) 2k). Show G(V,E) has () an
    Euler circuit.

Proof (The algorithm)
  • Step 3d PATCH C to C to form C

4
1
5
6
u
3
C v 1 2 3 v
C 3 6 5 4 1 3
19
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume (1) G is connected, (2)
    ("vÎV, deg(v) 2k). Show G(V,E) has () an
    Euler circuit.

Proof (The algorithm)
  • Step 3d PATCH C to C to form C

(i) Start at v
4
1
5
C v
6
u
3
C v 1 2 3 v
C 3 6 5 4 1 3
20
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume (1) G is connected, (2)
    ("vÎV, deg(v) 2k). Show G(V,E) has () an
    Euler circuit.

Proof (The algorithm)
  • Step 3d PATCH C to C to form C

(i) Start at v
(ii) Follow C to u
4
1
5
C v
2
v
6
u
3
C v 1 2 3 v
C 3 6 5 4 1 3
21
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume (1) G is connected, (2)
    ("vÎV, deg(v) 2k). Show G(V,E) has () an
    Euler circuit.

Proof (The algorithm)
  • Step 3d PATCH C to C to form C

(i) Start at v
(ii) Follow C to u
4
1
5
C v 1 2 3
2
v
6
u
3
C v 1 2 3 v
C 3 6 5 4 1 3
22
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume (1) G is connected, (2)
    ("vÎV, deg(v) 2k). Show G(V,E) has () an
    Euler circuit.

Proof (The algorithm)
  • Step 3d PATCH C to C to form C

(iii) Follow C from u all the way back to u
(i) Start at v
(ii) Follow C to u
4
1
5
C v 1 2 3
2
v
6
u
3
C v 1 2 3 v
C 3 6 5 4 1 3
23
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume (1) G is connected, (2)
    ("vÎV, deg(v) 2k). Show G(V,E) has () an
    Euler circuit.

Proof (The algorithm)
  • Step 3d PATCH C to C to form C

(iii) Follow C from u all the way back to u
(i) Start at v
(ii) Follow C to u
4
1
5
C v 1 2 3 6 5 4 1 3
2
v
6
u
3
C v 1 2 3 v
C 3 6 5 4 1 3
24
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume (1) G is connected, (2)
    ("vÎV, deg(v) 2k). Show G(V,E) has () an
    Euler circuit.

Proof (The algorithm)
  • Step 3d PATCH C to C to form C

(iii) Follow C from u all the way back to u
(i) Start at v
(iv) Return from u through untravelled portion
of C to v
(ii) Follow C to u
4
1
5
C v 1 2 3 6 5 4 1 3
2
v
6
u
3
C v 1 2 3 v
C 3 6 5 4 1 3
25
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume (1) G is connected, (2)
    ("vÎV, deg(v) 2k). Show G(V,E) has () an
    Euler circuit.

Proof (The algorithm)
  • Step 3d PATCH C to C to form C

(iii) Follow C from u all the way back to u
(i) Start at v
(iv) Return from u through untravelled portion
of C to v
(ii) Follow C to u
4
1
5
C v 1 2 3 6 5 4 1 3 v
2
v
6
u
3
C v 1 2 3 v
C 3 6 5 4 1 3
26
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume (1) G is connected, (2)
    ("vÎV, deg(v) 2k). Show G(V,E) has () an
    Euler circuit.

Proof (The algorithm)
  • Let C C. Go back to Step 3

4
1
5
2
v
6
3
C v 1 2 3 6 5 4 1 3 v
27
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume (1) G is connected, (2)
    ("vÎV, deg(v) 2k). Show G(V,E) has () an
    Euler circuit.

Proof (The algorithm)
  • Step 3 Does C contain every edge and vertex of
    G?
  • If Yes, then stop and output C, which is an
    Euler circuit.
  • If No (3a-3d)

4
1
5
2
v
6
3
C v 1 2 3 6 5 4 1 3 v
28
2.2 Euler Circuit Theorem (Proof )
  • The algorithm
  • Step 1 Pick any vertex v ÎV as the starting
    vertex.
  • Step 2 Pick any sequence of adjacent vertices
    and edges starting and ending at v, and never
    repeating an edge. Let this circuit be C.
  • Step 3 Does C contain every edge and vertex of
    G? If Yes, then stop and output C, which is an
    Euler circuit. If No, then
  • Step 3a Remove the circuit C from G creating G.
  • Step 3b Pick any vertex u common to C and G
  • Step 3c Pick any sequence of adjacent vertices
    and edges of G, starting and ending at u, never
    repeating an edge, creating another circuit C.
  • Step 3d PATCH C to C to form C
  • Start at v
  • Follow C to u
  • Follow C from u all the way back to u
  • Return from u through untravelled portion of C to
    v
  • Let C C.
  • Go to Step 3.

29
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume (1) G is connected, (2)
    ("vÎV, deg(v) 2k). Show G(V,E) has () an
    Euler circuit.
  • Proof
  • IF the algorithm terminates, THEN it will give an
    Euler circuit. This is true because Step 3
    checks whether all edges have been used, and step
    3a ensures that no edge is repeated in the
    circuit.
  • Step 3 Does C contain every edge and vertex of
    G? If Yes, then stop and output C, which is an
    Euler circuit. If No, then
  • Step 3a Remove the circuit C from G creating G.
  • Step 3b Pick any vertex u common to C and G
  • Step 3c Create another ciruit C startin from u.
  • Step 3d PATCH C to C to form C

30
2.2 Euler Circuit Theorem (Proof )
  • Proof () Assume (1) G is connected, (2)
    ("vÎV, deg(v) 2k). Show G(V,E) has () an
    Euler circuit.
  • Proof
  • (2) The algorithm will always terminate, because
  • The graph is finite,
  • Step 3b will always be successful since the
    graph is connected, any remaining edges must
    connect to the currently found circuit.
  • Step 2 and 3c will always be successful a new
    circuit can always be found since the degree of
    the vertex u is even.
  • Step 3 Does C contain every edge and vertex of
    G? If Yes, then stop and output C, which is an
    Euler circuit. If No, then
  • Step 3a Remove the circuit C from G creating G.
  • Step 3b Pick any vertex u common to C and G
  • Step 3c Create another circuit C starting from
    u
  • Step 3d PATCH C to C to form C

31
2.3 Example
  • (Euler Circuit Theorem) Let G(V,E) be a graph.
  • G has an Euler circuit iff G is connected AND
    every vertex of G has even degree.

Q Does the graph have an Euler circuit
A Yes
32
2.3 Example
  • (Euler Circuit Theorem) Let G(V,E) be a graph.
  • G has an Euler circuit iff G is connected AND
    every vertex of G has even degree.

Q Does the graph have an Euler circuit
A Yes
Q Where is the Circuit?
33
2.3 Example
  • (Euler Circuit Theorem) Let G(V,E) be a graph.
  • G has an Euler circuit iff G is connected AND
    every vertex of G has even degree.

Q Does the graph have an Euler circuit
A Yes
Q Where is the Circuit?
C a b c d a
d
i
a
f
j
e
b
h
c
g
34
2.3 Example
  • (Euler Circuit Theorem) Let G(V,E) be a graph.
  • G has an Euler circuit iff G is connected AND
    every vertex of G has even degree.

Q Does the graph have an Euler circuit
A Yes
Q Where is the Circuit?
C a b c d a
d
i
C d e g h j i d
a
C a b c d e g h j i d a
f
j
e
b
h
c
g
35
2.3 Example
  • (Euler Circuit Theorem) Let G(V,E) be a graph.
  • G has an Euler circuit iff G is connected AND
    every vertex of G has even degree.

Q Does the graph have an Euler circuit
A Yes
Q Where is the Circuit?
d
i
a
C a b c d e g h j i d a
f
j
e
b
h
c
g
36
2.3 Example
  • (Euler Circuit Theorem) Let G(V,E) be a graph.
  • G has an Euler circuit iff G is connected AND
    every vertex of G has even degree.

Q Does the graph have an Euler circuit
A Yes
Q Where is the Circuit?
d
i
a
C a b c d e g h j i d a
f
j
e
b
h
c
C e f h e
g
C a b c d e f h e g h j i d a
37
2.3 Example
  • (Euler Circuit Theorem) Let G(V,E) be a graph.
  • G has an Euler circuit iff G is connected AND
    every vertex of G has even degree.

Q Does the graph have an Euler circuit
A Yes
Q Where is the Circuit?
d
i
a
f
j
e
b
h
c
g
C a b c d e f h e g h j i d a
C is the Euler Circuit
38
2.3 Example
  • (Euler Circuit Theorem) Let G(V,E) be a graph.
  • G has an Euler circuit iff G is connected AND
    every vertex of G has even degree.

Q Does the graph have an Euler circuit
A No.
39
2.4. Euler Path (Definition)
  • Definition Let G(V,E) be a graph.
  • An EULER PATH from v to u (v ? u) for G is a
    simple path starting from v and ending at u and
    contains every edge in E.
  • Implications
  • simple path edges must be distinct
  • At most 1 traversal of each edge.
  • every edge in E
  • At least 1 traversal of each edge.

40
2.5 Euler Path Theorem
  • (Euler Path Theorem) Let G(V,E) be a graph.
  • G has an Euler Path from v to u iff G is
    connected AND v and u have odd degree and every
    other vertex of G has even degree.
  • Euler Path theorem is a COROLLARY (a consequence,
    a result) of Euler Circuit theorem.
  • Proof is left as an exercise (You need to use the
    Euler circuit theorem to prove the Euler Path
    theorem).

41
2.6 Euler Path Theorem (Example)
  • (Euler Path Theorem) Let G(V,E) be a graph.
  • G has an Euler Path from v to u iff G is
    connected AND v and u have odd degree and every
    other vertex of G has even degree.

Q Does the graph have an Euler path from a to d?
A Yes. Degree a and d are odd. All other
degree are even.
Q Where is the Path?
42
2.6 Euler Path Theorem (Example)
  • (Euler Path Theorem) Let G(V,E) be a graph.
  • G has an Euler Path from v to u iff G is
    connected AND v and u have odd degree and every
    other vertex of G has even degree.

Q Does the graph have an Euler path from a to d?
A Yes. Degree a and d are odd. All other
degree are even.
Q Where is the Path?
a
g
h
A a g h i e h f a
i
b
e
f
k
c
d
j
43
2.6 Euler Path Theorem (Example)
  • (Euler Path Theorem) Let G(V,E) be a graph.
  • G has an Euler Path from v to u iff G is
    connected AND v and u have odd degree and every
    other vertex of G has even degree.

Q Does the graph have an Euler path from a to d?
A Yes. Degree a and d are odd. All other
degree are even.
Q Where is the Path?
a
g
h
A a g h i e h f a
b f e k j d b c d
i
b
e
f
k
c
d
j
44
3.1. Hamiltonian Circuit (Definition)
  • Definition Let G(V,E) be a graph (simple or
    multigraph).
  • A HAMILTONIAN CIRCUIT for G is a elementary
    circuit that contains every vertex in V.
  • (Sir William Hamilton 1805-1865, Irish)
  • Implications
  • elementary circuit
  • vertices must be distinct
  • AT MOST ONE traversal of each vertex
  • every vertex in V
  • AT LEAST ONE traversal of each vertex
  • elementary circuit (edges distinct of course!)

45
3.2 Hamiltonian Circuit (Examples)
Q Is there a Hamiltonian circuit?
A Yes
g
b
d
a
f
h
e
c
g
46
3.3 Hamiltonian Circuit (Theorem?)
  • Q Given ANY graph G(V,E), is there a nice
    property which is a sufficient condition to
    determine whether the graph has a Hamiltonian
    circuit?
  • (Sufficient condition) Property Hamiltonian
    Circuit
  • A Dont know. No choice but to try all possible
    ways.
  • Q Are there special types of graphs which
    definitely have Hamiltonian circuits?
  • A Yes.
  • Q What are they?
  • A Graphs of some forms of geometric solids.
  • (i) Platonic Solids (ii) Archimedian solids

47
3.3 Hamiltonian Circuit (Special Cases)
(i) Platonic Solids
48
3.3 Hamiltonian Circuit (Special Cases)
(ii) Archidemian Solids
49
3.4. Hamiltonian Path (Definition)
  • Definition Let G(V,E) be a graph.
  • A HAMILTONIAN Path for G is a elementary path
    that contains every vertex in V.
  • Implications
  • elementary path
  • vertices must be distinct
  • AT MOST ONE traversal of each vertex
  • every vertex in V
  • AT LEAST ONE traversal of each vertex
  • Simple path (edges distinct of course!)

50
3.5 Hamiltonian Path (Example)
  • Example The following graph does not have a
    Hamiltonian circuit.

Q But does it have a Hamiltonian Path from a
to c? A Yes a e h f d b g c
51
3.5 Hamiltonian Path (Example)
  • Example The following graph does not have a
    Hamiltonian circuit.

Q Does it have a Hamiltonian Path from a to
g? A No.
52
3.5 Hamiltonian Path (Example)
  • Example The following graph does not have a
    Hamiltonian circuit.

Q Can there be Hamiltonian Paths starting from
g? A No.
53
3.5 Hamiltonian Path (Example)
  • Example The following graph does not have a
    Hamiltonian circuit.

Q Can there be Hamiltonian Paths ending at d? A
No.
54
3.5 Hamiltonian Path (Example)
  • Example The following graph does not have a
    Hamiltonian circuit.

Q Can there be a Hamiltonian Path ending at
a? A Yes. Example b g c d f e h
55
3.6 Hamiltonian Path (Theorem)
  • Q Given ANY graph G(V,E), is there a nice
    property which is a sufficient condition to
    determine whether the graph has a Hamiltonian
    path?
  • (Sufficient condition) Property Hamiltonian
    Path
  • Notes
  • (Sufficient condition) Property Hamiltonian
    Path
  • (Necessary condition) Property ? Hamiltonian
    Path
  • (Sufficient and necessary condition)
  • Property ? Hamiltonian Path

56
3.6 Hamiltonian Path (theorem)
Q Given ANY graph G(V,E), is there a nice
property which is a sufficient condition to
determine whether the graph has a Hamiltonian
path? (Sufficient condition) Property ?
Hamiltonian Path Please note that this does not
mean that Property ? Hamiltonian Path Yes
there is, but only for simple graph Sufficient
condition for a simple graph G with n vertices to
have Hamiltonian Path is every pair of vertices
must have .
Write a Comment
User Comments (0)
About PowerShow.com