discrete mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfasemi-eulerian graphis a graph...

67
Discrete Mathematics, 3rd lecture Eulerian and Hamiltonian graphs Peeter Laud Cybernetica AS September 20th, 2012 Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 1 / 22

Upload: others

Post on 25-Mar-2020

28 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Discrete Mathematics, 3rd lectureEulerian and Hamiltonian graphs

Peeter Laud

Cybernetica AS

September 20th, 2012

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 1 / 22

Page 2: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Recap: graphs

[Undirected] graph — triple (V ,E,E), where V — set of vertices, E —set of edges, E — the incidence function.

Walk in the graph is a sequence

v0e1— v1

e2— v2e3— v3

e4— . . . vk−1ek— vk

where v0, . . . , vk ∈ V , e1, . . . , ek ∈ E and E(ei) = {vi−1, vi}.

A walk is closed if its first and last vertex coincide.

A path is a walk where the vertices do not repeat.

A cycle is a closed path.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 2 / 22

Page 3: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Eulerian walks

DefinitionAn Eulerian walk in a graph G is a closed walk that contains eachedge exactly once.

An Eulerian graph is a connected graph that contains an Eulerianwalk.

Demanding connectedness removes some cases that do not add anythinginteresting, but just get in the way.

DefinitionA semi-Eulerian graph is a graph that has an open walk that contains eachedge exactly once.

A well-known class of puzzlesDraw the given figure without raising the pen from the paper and withoutrepeating a line.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 3 / 22

Page 4: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Examples

Example

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 4 / 22

Page 5: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Examples

Example

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 4 / 22

Page 6: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Examples

Example

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 4 / 22

Page 7: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

The “original task”

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 5 / 22

Page 8: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

The necessary and sufficient condition

TheoremLet G = (V ,E,E) be a connected graph. The following are equivalent

1 G is Eulerian;2 All vertices of G have even degree;

3 E can be partitioned into cycles.

“Partitioned into cycles”There are E1, . . . ,Ek ⊆ E, such that

Ei ∩ Ej = ∅, if i , j;

E1 ∪ · · · ∪ Ek = E;

For each i, there is a cycle Ci in G, such that the edges of Ci areprecisely the elements of Ei .

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 6 / 22

Page 9: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

The necessary and sufficient condition

TheoremLet G = (V ,E,E) be a connected graph. The following are equivalent

1 G is Eulerian;2 All vertices of G have even degree;3 E can be partitioned into cycles.

“Partitioned into cycles”There are E1, . . . ,Ek ⊆ E, such that

Ei ∩ Ej = ∅, if i , j;

E1 ∪ · · · ∪ Ek = E;

For each i, there is a cycle Ci in G, such that the edges of Ci areprecisely the elements of Ei .

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 6 / 22

Page 10: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (1)⇒ (2)

Let P be an Eulerian walk in graph G.

Let v ∈ V .The walk P enters v a number of times.

Denote by−−−→degP(v).

The walk P exits v a number of times.

Denote by←−−−degP(v).

How are deg(v),−−−→degP(v) and

←−−−degP(v) related?

deg(v) =−−−→degP(v) +

←−−−degP(v) and

−−−→degP(v) =

←−−−degP(v).

Hence deg(v) = 2−−−→degP(v) is an even number.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 7 / 22

Page 11: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (1)⇒ (2)

Let P be an Eulerian walk in graph G.

Let v ∈ V .The walk P enters v a number of times.

Denote by−−−→degP(v).

The walk P exits v a number of times.

Denote by←−−−degP(v).

How are deg(v),−−−→degP(v) and

←−−−degP(v) related?

deg(v) =−−−→degP(v) +

←−−−degP(v) and

−−−→degP(v) =

←−−−degP(v).

Hence deg(v) = 2−−−→degP(v) is an even number.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 7 / 22

Page 12: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (1)⇒ (2)

Let P be an Eulerian walk in graph G.

Let v ∈ V .

The walk P enters v a number of times.

Denote by−−−→degP(v).

The walk P exits v a number of times.

Denote by←−−−degP(v).

How are deg(v),−−−→degP(v) and

←−−−degP(v) related?

deg(v) =−−−→degP(v) +

←−−−degP(v) and

−−−→degP(v) =

←−−−degP(v).

Hence deg(v) = 2−−−→degP(v) is an even number.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 7 / 22

Page 13: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (1)⇒ (2)

Let P be an Eulerian walk in graph G.

Let v ∈ V .The walk P enters v a number of times.

Denote by−−−→degP(v).

The walk P exits v a number of times.

Denote by←−−−degP(v).

How are deg(v),−−−→degP(v) and

←−−−degP(v) related?

deg(v) =−−−→degP(v) +

←−−−degP(v) and

−−−→degP(v) =

←−−−degP(v).

Hence deg(v) = 2−−−→degP(v) is an even number.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 7 / 22

Page 14: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (1)⇒ (2)

Let P be an Eulerian walk in graph G.

Let v ∈ V .The walk P enters v a number of times.

Denote by−−−→degP(v).

The walk P exits v a number of times.Denote by

←−−−degP(v).

How are deg(v),−−−→degP(v) and

←−−−degP(v) related?

deg(v) =−−−→degP(v) +

←−−−degP(v) and

−−−→degP(v) =

←−−−degP(v).

Hence deg(v) = 2−−−→degP(v) is an even number.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 7 / 22

Page 15: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (1)⇒ (2)

Let P be an Eulerian walk in graph G.

Let v ∈ V .The walk P enters v a number of times.

Denote by−−−→degP(v).

The walk P exits v a number of times.Denote by

←−−−degP(v).

How are deg(v),−−−→degP(v) and

←−−−degP(v) related?

deg(v) =−−−→degP(v) +

←−−−degP(v) and

−−−→degP(v) =

←−−−degP(v).

Hence deg(v) = 2−−−→degP(v) is an even number.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 7 / 22

Page 16: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (1)⇒ (2)

Let P be an Eulerian walk in graph G.

Let v ∈ V .The walk P enters v a number of times.

Denote by−−−→degP(v).

The walk P exits v a number of times.Denote by

←−−−degP(v).

How are deg(v),−−−→degP(v) and

←−−−degP(v) related?

deg(v) =−−−→degP(v) +

←−−−degP(v) and

−−−→degP(v) =

←−−−degP(v).

Hence deg(v) = 2−−−→degP(v) is an even number.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 7 / 22

Page 17: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (1)⇒ (2)

Let P be an Eulerian walk in graph G.

Let v ∈ V .The walk P enters v a number of times.

Denote by−−−→degP(v).

The walk P exits v a number of times.Denote by

←−−−degP(v).

How are deg(v),−−−→degP(v) and

←−−−degP(v) related?

deg(v) =−−−→degP(v) +

←−−−degP(v) and

−−−→degP(v) =

←−−−degP(v).

Hence deg(v) = 2−−−→degP(v) is an even number.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 7 / 22

Page 18: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (2)⇒ (3)Ideas?

Given: degrees of all vertices are even.Also given: the graph is connected.

We need to partition E into cycles.

Try to find one cycle C and then partition E\C into cycles.

Looks like induction. Over what?

Over the size of E.

How about the assumption (2)? Will it still hold if we remove C?

How do the degrees of of vertices change if we remove a cycle?And where do we actually get that cycle from?

Remember something from the last lecture?

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 8 / 22

Page 19: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (2)⇒ (3)Ideas?

Given: degrees of all vertices are even.Also given: the graph is connected.

We need to partition E into cycles.

Try to find one cycle C and then partition E\C into cycles.

Looks like induction. Over what?

Over the size of E.

How about the assumption (2)? Will it still hold if we remove C?

How do the degrees of of vertices change if we remove a cycle?And where do we actually get that cycle from?

Remember something from the last lecture?

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 8 / 22

Page 20: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (2)⇒ (3)Ideas?

Given: degrees of all vertices are even.Also given: the graph is connected.

We need to partition E into cycles.

Try to find one cycle C and then partition E\C into cycles.

Looks like induction. Over what?

Over the size of E.

How about the assumption (2)? Will it still hold if we remove C?

How do the degrees of of vertices change if we remove a cycle?And where do we actually get that cycle from?

Remember something from the last lecture?

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 8 / 22

Page 21: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (2)⇒ (3)Ideas?

Given: degrees of all vertices are even.Also given: the graph is connected.

We need to partition E into cycles.

Try to find one cycle C and then partition E\C into cycles.

Looks like induction. Over what?

Over the size of E.

How about the assumption (2)? Will it still hold if we remove C?

How do the degrees of of vertices change if we remove a cycle?And where do we actually get that cycle from?

Remember something from the last lecture?

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 8 / 22

Page 22: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (2)⇒ (3)Ideas?

Given: degrees of all vertices are even.Also given: the graph is connected.

We need to partition E into cycles.

Try to find one cycle C and then partition E\C into cycles.

Looks like induction. Over what?

Over the size of E.

How about the assumption (2)? Will it still hold if we remove C?

How do the degrees of of vertices change if we remove a cycle?And where do we actually get that cycle from?

Remember something from the last lecture?

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 8 / 22

Page 23: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (2)⇒ (3)Ideas?

Given: degrees of all vertices are even.Also given: the graph is connected.

We need to partition E into cycles.

Try to find one cycle C and then partition E\C into cycles.

Looks like induction. Over what?

Over the size of E.

How about the assumption (2)? Will it still hold if we remove C?

How do the degrees of of vertices change if we remove a cycle?

And where do we actually get that cycle from?

Remember something from the last lecture?

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 8 / 22

Page 24: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (2)⇒ (3)Ideas?

Given: degrees of all vertices are even.Also given: the graph is connected.

We need to partition E into cycles.

Try to find one cycle C and then partition E\C into cycles.

Looks like induction. Over what?

Over the size of E.

How about the assumption (2)? Will it still hold if we remove C?

How do the degrees of of vertices change if we remove a cycle?And where do we actually get that cycle from?

Remember something from the last lecture?

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 8 / 22

Page 25: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (2)⇒ (3)Ideas?

Given: degrees of all vertices are even.Also given: the graph is connected.

We need to partition E into cycles.

Try to find one cycle C and then partition E\C into cycles.

Looks like induction. Over what?

Over the size of E.

How about the assumption (2)? Will it still hold if we remove C?

How do the degrees of of vertices change if we remove a cycle?And where do we actually get that cycle from?

Remember something from the last lecture?

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 8 / 22

Page 26: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (2)⇒ (3)

Induction basisIf E = ∅ then E can be partitioned to zero parts, each of which. . .

Induction step|E | > 0.

Let H be a connected component of G that has edges.

All vertices of H have degree > 1

/ 2

Given: all vertices have even degree.

Theorem. If all vertices have degree > 2, then there is a cycle C.

Remove [edges of] C from G. All vertices still have even degree.Let C1 ∪̇ · · · ∪̇ Ck be a partition of E\C into cycles.

Exists by the induction hypothesis.

Then E = C1 ∪̇ · · · ∪̇ Ck ∪̇ C

Exercise. Where did we use the connectedness of G?

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 9 / 22

Page 27: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (2)⇒ (3)

Induction basisIf E = ∅ then E can be partitioned to zero parts, each of which. . .

Induction step|E | > 0.

Let H be a connected component of G that has edges.

All vertices of H have degree > 1

/ 2

Given: all vertices have even degree.

Theorem. If all vertices have degree > 2, then there is a cycle C.

Remove [edges of] C from G. All vertices still have even degree.Let C1 ∪̇ · · · ∪̇ Ck be a partition of E\C into cycles.

Exists by the induction hypothesis.

Then E = C1 ∪̇ · · · ∪̇ Ck ∪̇ C

Exercise. Where did we use the connectedness of G?

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 9 / 22

Page 28: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (2)⇒ (3)

Induction basisIf E = ∅ then E can be partitioned to zero parts, each of which. . .

Induction step|E | > 0. Let H be a connected component of G that has edges.

All vertices of H have degree > 1

/ 2

Given: all vertices have even degree.

Theorem. If all vertices have degree > 2, then there is a cycle C.

Remove [edges of] C from G. All vertices still have even degree.Let C1 ∪̇ · · · ∪̇ Ck be a partition of E\C into cycles.

Exists by the induction hypothesis.

Then E = C1 ∪̇ · · · ∪̇ Ck ∪̇ C

Exercise. Where did we use the connectedness of G?

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 9 / 22

Page 29: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (2)⇒ (3)

Induction basisIf E = ∅ then E can be partitioned to zero parts, each of which. . .

Induction step|E | > 0. Let H be a connected component of G that has edges.

All vertices of H have degree > 1

/ 2

Given: all vertices have even degree.

Theorem. If all vertices have degree > 2, then there is a cycle C.

Remove [edges of] C from G. All vertices still have even degree.Let C1 ∪̇ · · · ∪̇ Ck be a partition of E\C into cycles.

Exists by the induction hypothesis.

Then E = C1 ∪̇ · · · ∪̇ Ck ∪̇ C

Exercise. Where did we use the connectedness of G?

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 9 / 22

Page 30: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (2)⇒ (3)

Induction basisIf E = ∅ then E can be partitioned to zero parts, each of which. . .

Induction step|E | > 0. Let H be a connected component of G that has edges.

All vertices of H have degree > 1

/ 2

Given: all vertices have even degree.

Theorem. If all vertices have degree > 2, then there is a cycle C.

Remove [edges of] C from G. All vertices still have even degree.Let C1 ∪̇ · · · ∪̇ Ck be a partition of E\C into cycles.

Exists by the induction hypothesis.

Then E = C1 ∪̇ · · · ∪̇ Ck ∪̇ C

Exercise. Where did we use the connectedness of G?

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 9 / 22

Page 31: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (2)⇒ (3)

Induction basisIf E = ∅ then E can be partitioned to zero parts, each of which. . .

Induction step|E | > 0. Let H be a connected component of G that has edges.

All vertices of H have degree > 1/ 2

Given: all vertices have even degree.

Theorem. If all vertices have degree > 2, then there is a cycle C.

Remove [edges of] C from G. All vertices still have even degree.Let C1 ∪̇ · · · ∪̇ Ck be a partition of E\C into cycles.

Exists by the induction hypothesis.

Then E = C1 ∪̇ · · · ∪̇ Ck ∪̇ C

Exercise. Where did we use the connectedness of G?

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 9 / 22

Page 32: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (2)⇒ (3)

Induction basisIf E = ∅ then E can be partitioned to zero parts, each of which. . .

Induction step|E | > 0. Let H be a connected component of G that has edges.

All vertices of H have degree > 1/ 2

Given: all vertices have even degree.

Theorem. If all vertices have degree > 2, then there is a cycle C.

Remove [edges of] C from G. All vertices still have even degree.Let C1 ∪̇ · · · ∪̇ Ck be a partition of E\C into cycles.

Exists by the induction hypothesis.

Then E = C1 ∪̇ · · · ∪̇ Ck ∪̇ C

Exercise. Where did we use the connectedness of G?

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 9 / 22

Page 33: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (2)⇒ (3)

Induction basisIf E = ∅ then E can be partitioned to zero parts, each of which. . .

Induction step|E | > 0. Let H be a connected component of G that has edges.

All vertices of H have degree > 1/ 2

Given: all vertices have even degree.

Theorem. If all vertices have degree > 2, then there is a cycle C.

Remove [edges of] C from G. All vertices still have even degree.

Let C1 ∪̇ · · · ∪̇ Ck be a partition of E\C into cycles.

Exists by the induction hypothesis.

Then E = C1 ∪̇ · · · ∪̇ Ck ∪̇ C

Exercise. Where did we use the connectedness of G?

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 9 / 22

Page 34: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (2)⇒ (3)

Induction basisIf E = ∅ then E can be partitioned to zero parts, each of which. . .

Induction step|E | > 0. Let H be a connected component of G that has edges.

All vertices of H have degree > 1/ 2

Given: all vertices have even degree.

Theorem. If all vertices have degree > 2, then there is a cycle C.

Remove [edges of] C from G. All vertices still have even degree.Let C1 ∪̇ · · · ∪̇ Ck be a partition of E\C into cycles.

Exists by the induction hypothesis.

Then E = C1 ∪̇ · · · ∪̇ Ck ∪̇ C

Exercise. Where did we use the connectedness of G?

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 9 / 22

Page 35: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (2)⇒ (3)

Induction basisIf E = ∅ then E can be partitioned to zero parts, each of which. . .

Induction step|E | > 0. Let H be a connected component of G that has edges.

All vertices of H have degree > 1/ 2

Given: all vertices have even degree.

Theorem. If all vertices have degree > 2, then there is a cycle C.

Remove [edges of] C from G. All vertices still have even degree.Let C1 ∪̇ · · · ∪̇ Ck be a partition of E\C into cycles.

Exists by the induction hypothesis.

Then E = C1 ∪̇ · · · ∪̇ Ck ∪̇ C

Exercise. Where did we use the connectedness of G?

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 9 / 22

Page 36: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (2)⇒ (3)

Induction basisIf E = ∅ then E can be partitioned to zero parts, each of which. . .

Induction step|E | > 0. Let H be a connected component of G that has edges.

All vertices of H have degree > 1/ 2

Given: all vertices have even degree.

Theorem. If all vertices have degree > 2, then there is a cycle C.

Remove [edges of] C from G. All vertices still have even degree.Let C1 ∪̇ · · · ∪̇ Ck be a partition of E\C into cycles.

Exists by the induction hypothesis.

Then E = C1 ∪̇ · · · ∪̇ Ck ∪̇ C

Exercise. Where did we use the connectedness of G?

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 9 / 22

Page 37: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (3)⇒ (1)Ideas?

Given: the edges of a connected graph G = (V ,E,E) are partitioned tocycles.

We have cycles C1, . . . ,Ck without common edges. We have to passthrough all of them.

Looks like induction again.

Where is connectedness important?

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 10 / 22

Page 38: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (3)⇒ (1)Ideas?

Given: the edges of a connected graph G = (V ,E,E) are partitioned tocycles.

We have cycles C1, . . . ,Ck without common edges. We have to passthrough all of them.

Looks like induction again.

Where is connectedness important?

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 10 / 22

Page 39: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (3)⇒ (1)Ideas?

Given: the edges of a connected graph G = (V ,E,E) are partitioned tocycles.

We have cycles C1, . . . ,Ck without common edges. We have to passthrough all of them.

Looks like induction again.

Where is connectedness important?

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 10 / 22

Page 40: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (3)⇒ (1)

Using connectedness

E = C1 ∪̇ · · · ∪̇ Ck . We may assume w.l.o.g. that∀i ∈ {2, . . . , k }.∃j ∈ {1, . . . , i − 1}, such that Ci and Cj have a commonvertex.

Induction basisE is a single cycle. Eulerian walk goes through it.

Induction stepLet P be a closed walk passing through edges in C1 ∪ · · · ∪ Ck−1.

Exists because of the induction hypothesis.

P passes through some vertex on Ck .

At this vertex, interrupt P, pass around Ck , continue with P.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 11 / 22

Page 41: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (3)⇒ (1)

Using connectedness

E = C1 ∪̇ · · · ∪̇ Ck . We may assume w.l.o.g. that∀i ∈ {2, . . . , k }.∃j ∈ {1, . . . , i − 1}, such that Ci and Cj have a commonvertex.

Induction basisE is a single cycle. Eulerian walk goes through it.

Induction stepLet P be a closed walk passing through edges in C1 ∪ · · · ∪ Ck−1.

Exists because of the induction hypothesis.

P passes through some vertex on Ck .

At this vertex, interrupt P, pass around Ck , continue with P.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 11 / 22

Page 42: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof (3)⇒ (1)

Using connectedness

E = C1 ∪̇ · · · ∪̇ Ck . We may assume w.l.o.g. that∀i ∈ {2, . . . , k }.∃j ∈ {1, . . . , i − 1}, such that Ci and Cj have a commonvertex.

Induction basisE is a single cycle. Eulerian walk goes through it.

Induction stepLet P be a closed walk passing through edges in C1 ∪ · · · ∪ Ck−1.

Exists because of the induction hypothesis.

P passes through some vertex on Ck .

At this vertex, interrupt P, pass around Ck , continue with P.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 11 / 22

Page 43: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Algorithm for finding an Eulerian walk

Implicit in the proof of the previous theorem.

1 Partition the edges of the graph into cycles.2 Pass through all of them.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 12 / 22

Page 44: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Semi-Eulerian graphs

TheoremA connected graph is semi-Eulerian iff it has exactly two vertices with odddegree.

Exercise. Prove it, by using the previous theorem in a material way.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 13 / 22

Page 45: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Hamiltonian graphs

DefinitionHamiltonian cycle in graph G is a cycle that passes through eachvertex exactly once.

Hamiltonian path in graph G is an open path that passes througheach vertex exactly once.

If a graph has a Hamiltonian cycle, it is called a Hamiltonian graph.

If a graph has a Hamiltonian path (but no cycle), it is called asemi-Hamiltonian graph.

In Hamiltonicity considerations, double edges and loops are irrelevant.

Hence we only consider simple graphs G = (V ,E).

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 14 / 22

Page 46: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Hamiltonian graphs

DefinitionHamiltonian cycle in graph G is a cycle that passes through eachvertex exactly once.

Hamiltonian path in graph G is an open path that passes througheach vertex exactly once.

If a graph has a Hamiltonian cycle, it is called a Hamiltonian graph.

If a graph has a Hamiltonian path (but no cycle), it is called asemi-Hamiltonian graph.

In Hamiltonicity considerations, double edges and loops are irrelevant.

Hence we only consider simple graphs G = (V ,E).

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 14 / 22

Page 47: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Sir William Rowan Hamilton’s Icosian game

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 15 / 22

Page 48: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Necessary and sufficient conditions for Hamiltonicity

For Eulericity, there was a nice, locally checkable necessary andsufficient condition.

No such condition is known for Hamiltonicity.The question, whether a given graph G is Hamiltonian or not, isNP-complete.

Hence the existence of a simple algorithm for checking it is unlikely.

There exist easily checkable, sufficient, but not necessary conditionsfor Hamiltonicity.

Many of them are are variations of “if a graph has many edges then it isHamiltonian”.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 16 / 22

Page 49: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

If a graph has many edges. . .

Theorem (Dirac, 1952)If a simple graph G = (V ,E) with |V | = n > 3 satisfies

∀v ∈ V : deg(v) > n/2

then G is Hamiltonian.

Follows trivially from

Theorem (Ore, 1960)If a simple graph G = (V ,E) with |V | = n > 3 satisfies

∀u,w ∈ V :(if (u,w) < E then deg(u) + deg(w) > n

)(O)

then G is Hamiltonian.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 17 / 22

Page 50: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

If a graph has many edges. . .

Theorem (Dirac, 1952)If a simple graph G = (V ,E) with |V | = n > 3 satisfies

∀v ∈ V : deg(v) > n/2

then G is Hamiltonian.

Follows trivially from

Theorem (Ore, 1960)If a simple graph G = (V ,E) with |V | = n > 3 satisfies

∀u,w ∈ V :(if (u,w) < E then deg(u) + deg(w) > n

)(O)

then G is Hamiltonian.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 17 / 22

Page 51: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof of Ore theoremn = 3

If n = 3 then the only graph satisfying (O) is K3. It is Hamiltonian.

Exercise. Verify that only K3 satisfies (O).

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 18 / 22

Page 52: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof of Ore theoremGoing to the limit

Let n > 4.

Do proof by contradictionAssume there exists a non-Hamiltonian graph G satisfying (O).

LemmaIf G = (V ,E) satisfies (O) and (u, v) < E, then G′ = (V ,E ∪ {(u, v)}) alsosatisfies (O).

Exercise. Prove it.

Lemma (The limit graph G∗)There exists a graph G∗ = (V ,E∗) satisfying (O) and E ⊆ E∗, such that

G∗ is not Hamiltonian.

The addition of any one edge would make G∗ Hamiltonian.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 19 / 22

Page 53: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Why can and should we go to the limit?

Proof of the lemmaAdd arbitrary edges to G until you reach that G∗.

By adding edges to G, we will eventually obtain a Hamiltonian graph.Because Kn is Hamiltonian.And we can only add a finite number of edges.

We stop one step before obtaining a Hamiltonian graph. . . when there is no way to add one more edge.

We know more about G∗ than we know about G.

So we can argue more about it.

Note that G∗ , Kn.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 20 / 22

Page 54: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Why can and should we go to the limit?

Proof of the lemmaAdd arbitrary edges to G until you reach that G∗.

By adding edges to G, we will eventually obtain a Hamiltonian graph.Because Kn is Hamiltonian.And we can only add a finite number of edges.

We stop one step before obtaining a Hamiltonian graph. . . when there is no way to add one more edge.

We know more about G∗ than we know about G.

So we can argue more about it.

Note that G∗ , Kn.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 20 / 22

Page 55: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof of Ore theoremG∗ is semi-Hamiltonian

Let e = (u,w) be an edge not present in G∗.

G∗ ∪ {e} is Hamiltonian. Let C be a Hamiltonian cycle in G∗ ∪ {e}.

C uses the edge e.C\{e} is a path starting in u and ending in w and going through allvertices in V .

It uses only edges in E∗.Its length is n − 1.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 21 / 22

Page 56: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof of Ore theoremG∗ is semi-Hamiltonian

Let e = (u,w) be an edge not present in G∗.

G∗ ∪ {e} is Hamiltonian. Let C be a Hamiltonian cycle in G∗ ∪ {e}.

C uses the edge e.C\{e} is a path starting in u and ending in w and going through allvertices in V .

It uses only edges in E∗.Its length is n − 1.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 21 / 22

Page 57: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof of Ore theoremG∗ is semi-Hamiltonian

Let e = (u,w) be an edge not present in G∗.

G∗ ∪ {e} is Hamiltonian. Let C be a Hamiltonian cycle in G∗ ∪ {e}.

C uses the edge e.C\{e} is a path starting in u and ending in w and going through allvertices in V .

It uses only edges in E∗.Its length is n − 1.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 21 / 22

Page 58: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof of Ore theoremG∗ is semi-Hamiltonian

Let e = (u,w) be an edge not present in G∗.

G∗ ∪ {e} is Hamiltonian. Let C be a Hamiltonian cycle in G∗ ∪ {e}.

C uses the edge e.

C\{e} is a path starting in u and ending in w and going through allvertices in V .

It uses only edges in E∗.Its length is n − 1.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 21 / 22

Page 59: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof of Ore theoremG∗ is semi-Hamiltonian

Let e = (u,w) be an edge not present in G∗.

G∗ ∪ {e} is Hamiltonian. Let C be a Hamiltonian cycle in G∗ ∪ {e}.

C uses the edge e.C\{e} is a path starting in u and ending in w and going through allvertices in V .

It uses only edges in E∗.Its length is n − 1.

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 21 / 22

Page 60: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof of Ore theoremG∗ is actually Hamiltonian

The Hamiltonian path.

How many edges have their right end-point connected to u?

deg(u).

How many edges have their left end-point connected to w?

deg(w).

There are n − 1 edges on the path. deg(u) + deg(w) > n.

Some edge has both end-points connected.

These edges give us a Hamiltonian cycle. �

u w

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 22 / 22

Page 61: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof of Ore theoremG∗ is actually Hamiltonian

The Hamiltonian path.

How many edges have their right end-point connected to u?

deg(u).

How many edges have their left end-point connected to w?

deg(w).

There are n − 1 edges on the path. deg(u) + deg(w) > n.

Some edge has both end-points connected.

These edges give us a Hamiltonian cycle. �

u w

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 22 / 22

Page 62: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof of Ore theoremG∗ is actually Hamiltonian

The Hamiltonian path.

How many edges have their right end-point connected to u? deg(u).

How many edges have their left end-point connected to w?

deg(w).

There are n − 1 edges on the path. deg(u) + deg(w) > n.

Some edge has both end-points connected.

These edges give us a Hamiltonian cycle. �

u w

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 22 / 22

Page 63: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof of Ore theoremG∗ is actually Hamiltonian

The Hamiltonian path.

How many edges have their right end-point connected to u? deg(u).

How many edges have their left end-point connected to w?

deg(w).

There are n − 1 edges on the path. deg(u) + deg(w) > n.

Some edge has both end-points connected.

These edges give us a Hamiltonian cycle. �

u w

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 22 / 22

Page 64: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof of Ore theoremG∗ is actually Hamiltonian

The Hamiltonian path.

How many edges have their right end-point connected to u? deg(u).

How many edges have their left end-point connected to w? deg(w).

There are n − 1 edges on the path. deg(u) + deg(w) > n.

Some edge has both end-points connected.

These edges give us a Hamiltonian cycle. �

u w

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 22 / 22

Page 65: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof of Ore theoremG∗ is actually Hamiltonian

The Hamiltonian path.

How many edges have their right end-point connected to u? deg(u).

How many edges have their left end-point connected to w? deg(w).

There are n − 1 edges on the path. deg(u) + deg(w) > n.

Some edge has both end-points connected.

These edges give us a Hamiltonian cycle. �

u w

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 22 / 22

Page 66: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof of Ore theoremG∗ is actually Hamiltonian

The Hamiltonian path.

How many edges have their right end-point connected to u? deg(u).

How many edges have their left end-point connected to w? deg(w).

There are n − 1 edges on the path. deg(u) + deg(w) > n.

Some edge has both end-points connected.

These edges give us a Hamiltonian cycle. �

u w

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 22 / 22

Page 67: Discrete Mathematics, 3rd lecturepeeter/teaching/diskmat12s/loeng3.pdfAsemi-Eulerian graphis a graph that has an open walk that contains each edge exactly once. A well-known class

Proof of Ore theoremG∗ is actually Hamiltonian

The Hamiltonian path.

How many edges have their right end-point connected to u? deg(u).

How many edges have their left end-point connected to w? deg(w).

There are n − 1 edges on the path. deg(u) + deg(w) > n.

Some edge has both end-points connected.

These edges give us a Hamiltonian cycle. �

u w

Peeter Laud (Cybernetica) Discrete Mathematics, 3rd lecture September 20th, 2012 22 / 22