CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic...

62
CS 207m 2018: Discrete Structures (Minor) Graph theory Basic terminology, Eulerian walks Lecture 14 Mar 07 2018 1

Transcript of CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic...

Page 1: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

CS 207m 2018: Discrete Structures (Minor)

Graph theoryBasic terminology, Eulerian walks

Lecture 14Mar 07 2018

1

Page 2: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Topic 3: Graph theory

Topics covered in the last three lectures

I Pigeon-Hole Principle and its extensions.

I A glimpse of Ramsey theory

2

Page 3: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Topic 3: Graph theory

Topics covered in the last three lectures

I Pigeon-Hole Principle and its extensions.

I A glimpse of Ramsey theory

I Ramsey numbers R(k, `): Existence of regularsub-structures in large enough general structures.

2

Page 4: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Topic 3: Graph theory

Topics covered in the last three lectures

I Pigeon-Hole Principle and its extensions.

I A glimpse of Ramsey theory

I Ramsey numbers R(k, `): Existence of regularsub-structures in large enough general structures.

I Structures = Graphs,

2

Page 5: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Topic 3: Graph theory

Topics covered in the last three lectures

I Pigeon-Hole Principle and its extensions.

I A glimpse of Ramsey theory

I Ramsey numbers R(k, `): Existence of regularsub-structures in large enough general structures.

I Structures = Graphs, regular= monochromatic/complete

2

Page 6: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Topic 3: Graph theory

Topics covered in the last three lectures

I Pigeon-Hole Principle and its extensions.

I A glimpse of Ramsey theory

I Ramsey numbers R(k, `): Existence of regularsub-structures in large enough general structures.

I Structures = Graphs, regular= monochromatic/complete

Next topic

Graphs and their properties!

2

Page 7: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Topic 3: Graph theory

Textbook Reference

I Introduction to Graph Theory, 2nd Ed., by Douglas West.

I Low cost Indian edition available, published by PHILearning Private Ltd.

Topics covered in the next two lectures:

I What is a Graph?

I Paths, cycles, walks and trails; connected graphs.

I Eulerian graphs and a characterization in terms of degreesof vertices.

I Bipartite graphs and a characterization in terms of oddlength cycles.

Reference: Section 1.1, 1.2 of Chapter 1 from Douglas West.

3

Page 8: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Topic 3: Graph theory

Textbook Reference

I Introduction to Graph Theory, 2nd Ed., by Douglas West.

I Low cost Indian edition available, published by PHILearning Private Ltd.

Topics covered in the next two lectures:

I What is a Graph?

I Paths, cycles, walks and trails; connected graphs.

I Eulerian graphs and a characterization in terms of degreesof vertices.

I Bipartite graphs and a characterization in terms of oddlength cycles.

Reference: Section 1.1, 1.2 of Chapter 1 from Douglas West.

3

Page 9: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

What are graphs

Recall:

Definition

A simple graph G is a pair (V,E) of a set of vertices/nodes Vand edges E between unordered pairs of vertices calledend-points: e = vu means that e is an edge between v and u(u 6= v).

I What about loops?I What about directed edges?I What about multiple edges?

General Definition

A graph G is a triple V,E,R where V is a set of vertices, E is aset of edges and R ⊆ E × V × V is a relation that associateseach edge with two vertices called its end-points.

We will consider only finite graphs (i.e., |V |, |E| are finite) andoften deal with simple graphs.

4

Page 10: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

What are graphs

Recall:

Definition

A simple graph G is a pair (V,E) of a set of vertices/nodes Vand edges E between unordered pairs of vertices calledend-points: e = vu means that e is an edge between v and u(u 6= v).

I What about loops?I What about directed edges?I What about multiple edges?

General Definition

A graph G is a triple V,E,R where V is a set of vertices, E is aset of edges and R ⊆ E × V × V is a relation that associateseach edge with two vertices called its end-points.

We will consider only finite graphs (i.e., |V |, |E| are finite) andoften deal with simple graphs.

4

Page 11: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

What are graphs

Recall:

Definition

A simple graph G is a pair (V,E) of a set of vertices/nodes Vand edges E between unordered pairs of vertices calledend-points: e = vu means that e is an edge between v and u(u 6= v).

I What about loops?I What about directed edges?I What about multiple edges?

General Definition

A graph G is a triple V,E,R where V is a set of vertices, E is aset of edges and R ⊆ E × V × V is a relation that associateseach edge with two vertices called its end-points.

We will consider only finite graphs (i.e., |V |, |E| are finite) andoften deal with simple graphs.

4

Page 12: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Konigsberg Bridge problem

I In 18th century Prussia, the city on river Pregel...

I Question was to find a walk from home, crossing everybridge exactly once and returning home.

I Leonard Euler showed in 1735 that this is impossible.

I Thus, he “gave birth” to the area of graph theory.

5

Page 13: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Konigsberg Bridge problem

I In 18th century Prussia, the city on river Pregel...

I Question was to find a walk from home, crossing everybridge exactly once and returning home.

I Leonard Euler showed in 1735 that this is impossible.

I Thus, he “gave birth” to the area of graph theory.

5

Page 14: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Konigsberg Bridge problem

I In 18th century Prussia, the city on river Pregel...

I Question was to find a walk from home, crossing everybridge exactly once and returning home.

I Leonard Euler showed in 1735 that this is impossible.

I Thus, he “gave birth” to the area of graph theory.

5

Page 15: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Konigsberg Bridge problem

I Qn: Find a walk from home, which crosses every bridgeexactly once and returns home.

I Leonard Euler showed in 1735 that this is impossible. Theargument is as follows:

I Each time you enter or leave a vertex, you use an edge.I So each vertex must be connected to an even no. of vertices.I Which is not the case here, hence it is impossible.

I Clearly, this is a sufficient condition, but is it necessary?I If every vertex is connected to an even no. of vertices in a

graph, is there such a walk? This is called Eulerian walk.

6

Page 16: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Konigsberg Bridge problem

I Qn: Find a walk from home, which crosses every bridgeexactly once and returns home.

I Leonard Euler showed in 1735 that this is impossible. Theargument is as follows:

I Each time you enter or leave a vertex, you use an edge.

I So each vertex must be connected to an even no. of vertices.I Which is not the case here, hence it is impossible.

I Clearly, this is a sufficient condition, but is it necessary?I If every vertex is connected to an even no. of vertices in a

graph, is there such a walk? This is called Eulerian walk.

6

Page 17: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Konigsberg Bridge problem

I Qn: Find a walk from home, which crosses every bridgeexactly once and returns home.

I Leonard Euler showed in 1735 that this is impossible. Theargument is as follows:

I Each time you enter or leave a vertex, you use an edge.I So each vertex must be connected to an even no. of vertices.

I Which is not the case here, hence it is impossible.I Clearly, this is a sufficient condition, but is it necessary?I If every vertex is connected to an even no. of vertices in a

graph, is there such a walk? This is called Eulerian walk.

6

Page 18: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Konigsberg Bridge problem

I Qn: Find a walk from home, which crosses every bridgeexactly once and returns home.

I Leonard Euler showed in 1735 that this is impossible. Theargument is as follows:

I Each time you enter or leave a vertex, you use an edge.I So each vertex must be connected to an even no. of vertices.I Which is not the case here, hence it is impossible.

I Clearly, this is a sufficient condition, but is it necessary?I If every vertex is connected to an even no. of vertices in a

graph, is there such a walk? This is called Eulerian walk.

6

Page 19: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Konigsberg Bridge problem

I Qn: Find a walk from home, which crosses every bridgeexactly once and returns home.

I Leonard Euler showed in 1735 that this is impossible. Theargument is as follows:

I Each time you enter or leave a vertex, you use an edge.I So each vertex must be connected to an even no. of vertices.I Which is not the case here, hence it is impossible.

I Clearly, this is a sufficient condition, but is it necessary?

I If every vertex is connected to an even no. of vertices in agraph, is there such a walk? This is called Eulerian walk.

6

Page 20: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Konigsberg Bridge problem

I Qn: Find a walk from home, which crosses every bridgeexactly once and returns home.

I Leonard Euler showed in 1735 that this is impossible. Theargument is as follows:

I Each time you enter or leave a vertex, you use an edge.I So each vertex must be connected to an even no. of vertices.I Which is not the case here, hence it is impossible.

I Clearly, this is a sufficient condition, but is it necessary?I If every vertex is connected to an even no. of vertices in a

graph, is there such a walk?

This is called Eulerian walk.

6

Page 21: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Konigsberg Bridge problem

I Qn: Find a walk from home, which crosses every bridgeexactly once and returns home.

I Leonard Euler showed in 1735 that this is impossible. Theargument is as follows:

I Each time you enter or leave a vertex, you use an edge.I So each vertex must be connected to an even no. of vertices.I Which is not the case here, hence it is impossible.

I Clearly, this is a sufficient condition, but is it necessary?I If every vertex is connected to an even no. of vertices in a

graph, is there such a walk? This is called Eulerian walk.6

Page 22: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Basic terminology

The degree d(v) of a vertex v (in an undirected loopless graph)is the number of edges incident to it, i.e., |{vw ∈ E | w ∈ V }|.A vertex of degree 0 is called an isolated vertex.

I A walk is a sequence of vertices v1, . . . vk such that∀i ∈ {1, . . . k− 1}, (vi, vi+1) ∈ E. The vertices v1 and vk arecalled the end-points and others are called internal vertices.

I A path is a walk in which no vertex is repeated. Its lengthis the number of edges in it.

I A walk is called closed if it starts and ends with the samevertex, i.e., its endpoints are the same.

I A closed walk is called a cycle if its internal vertices are alldistinct from each other and from the end-point.

A graph is called connected if there is a path (or walk) betweenany two of its vertices.

7

Page 23: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Basic terminology

The degree d(v) of a vertex v (in an undirected loopless graph)is the number of edges incident to it, i.e., |{vw ∈ E | w ∈ V }|.A vertex of degree 0 is called an isolated vertex.

I A walk is a sequence of vertices v1, . . . vk such that∀i ∈ {1, . . . k− 1}, (vi, vi+1) ∈ E. The vertices v1 and vk arecalled the end-points and others are called internal vertices.

I A path is a walk in which no vertex is repeated. Its lengthis the number of edges in it.

I A walk is called closed if it starts and ends with the samevertex, i.e., its endpoints are the same.

I A closed walk is called a cycle if its internal vertices are alldistinct from each other and from the end-point.

A graph is called connected if there is a path (or walk) betweenany two of its vertices.

7

Page 24: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Basic terminology

The degree d(v) of a vertex v (in an undirected loopless graph)is the number of edges incident to it, i.e., |{vw ∈ E | w ∈ V }|.A vertex of degree 0 is called an isolated vertex.

I A walk is a sequence of vertices v1, . . . vk such that∀i ∈ {1, . . . k− 1}, (vi, vi+1) ∈ E. The vertices v1 and vk arecalled the end-points and others are called internal vertices.

I A path is a walk in which no vertex is repeated. Its lengthis the number of edges in it.

I A walk is called closed if it starts and ends with the samevertex, i.e., its endpoints are the same.

I A closed walk is called a cycle if its internal vertices are alldistinct from each other and from the end-point.

A graph is called connected if there is a path (or walk) betweenany two of its vertices.

7

Page 25: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Basic terminology

The degree d(v) of a vertex v (in an undirected loopless graph)is the number of edges incident to it, i.e., |{vw ∈ E | w ∈ V }|.A vertex of degree 0 is called an isolated vertex.

I A walk is a sequence of vertices v1, . . . vk such that∀i ∈ {1, . . . k− 1}, (vi, vi+1) ∈ E. The vertices v1 and vk arecalled the end-points and others are called internal vertices.

I A path is a walk in which no vertex is repeated. Its lengthis the number of edges in it.

I A walk is called closed if it starts and ends with the samevertex, i.e., its endpoints are the same.

I A closed walk is called a cycle if its internal vertices are alldistinct from each other and from the end-point.

A graph is called connected if there is a path (or walk) betweenany two of its vertices.

7

Page 26: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Basic terminology

The degree d(v) of a vertex v (in an undirected loopless graph)is the number of edges incident to it, i.e., |{vw ∈ E | w ∈ V }|.A vertex of degree 0 is called an isolated vertex.

I A walk is a sequence of vertices v1, . . . vk such that∀i ∈ {1, . . . k− 1}, (vi, vi+1) ∈ E. The vertices v1 and vk arecalled the end-points and others are called internal vertices.

I A path is a walk in which no vertex is repeated. Its lengthis the number of edges in it.

I A walk is called closed if it starts and ends with the samevertex, i.e., its endpoints are the same.

I A closed walk is called a cycle if its internal vertices are alldistinct from each other and from the end-point.

A graph is called connected if there is a path (or walk) betweenany two of its vertices.

7

Page 27: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Basic terminology

The degree d(v) of a vertex v (in an undirected loopless graph)is the number of edges incident to it, i.e., |{vw ∈ E | w ∈ V }|.A vertex of degree 0 is called an isolated vertex.

I A walk is a sequence of vertices v1, . . . vk such that∀i ∈ {1, . . . k− 1}, (vi, vi+1) ∈ E. The vertices v1 and vk arecalled the end-points and others are called internal vertices.

I A path is a walk in which no vertex is repeated. Its lengthis the number of edges in it.

I A walk is called closed if it starts and ends with the samevertex, i.e., its endpoints are the same.

I A closed walk is called a cycle if its internal vertices are alldistinct from each other and from the end-point.

A graph is called connected if there is a path (or walk) betweenany two of its vertices.

7

Page 28: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Basic terminology: some exercises

v1 v2 v3

v4 v5 v6

v7 v8

1. Give examples each of the following in the above graph:1.1 All vertices of degree 31.2 A walk of length 51.3 A path of length 51.4 A closed walk of length 61.5 A cycle of length 6

2. True or False: (a) If a graph is not connected, it must havean isolated vertex.(b) A graph is connected iff some vertex is connected toevery other vertex.

8

Page 29: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Basic terminology: some exercises

v1 v2 v3

v4 v5 v6

v7 v8

1. Give examples each of the following in the above graph:1.1 All vertices of degree 31.2 A walk of length 51.3 A path of length 51.4 A closed walk of length 61.5 A cycle of length 6

2. True or False: (a) If a graph is not connected, it must havean isolated vertex.(b) A graph is connected iff some vertex is connected toevery other vertex.

8

Page 30: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Eulerian graphs

Definition

A graph is called Eulerian if it has a closed walk that containsall edges, and each edge occurs exactly once. Such a walk iscalled an Eulerian walk.

I If G is Eulerian, each vertex must have an even degree.I This is a necessary condition, but is it sufficient?

Theorem

A graph G with no isolated vertices is Eulerian iff it isconnected and all its vertices have even degree.

Proof: ( =⇒ )I Suppose G is Eulerian: every vertex has even degree.

I each passage through a vertex uses two edges (in and out).I at the first vertex first edge is paired with last.

I Any two edges are in the same walk implies graph isconnected (unless it has isolated vertices).

9

Page 31: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Eulerian graphs

Definition

A graph is called Eulerian if it has a closed walk that containsall edges, and each edge occurs exactly once. Such a walk iscalled an Eulerian walk.

I If G is Eulerian, each vertex must have an even degree.I This is a necessary condition, but is it sufficient?

Theorem

A graph G with no isolated vertices is Eulerian iff it isconnected and all its vertices have even degree.

Proof: ( =⇒ )I Suppose G is Eulerian: every vertex has even degree.

I each passage through a vertex uses two edges (in and out).I at the first vertex first edge is paired with last.

I Any two edges are in the same walk implies graph isconnected (unless it has isolated vertices).

9

Page 32: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Eulerian graphs

Definition

A graph is called Eulerian if it has a closed walk that containsall edges, and each edge occurs exactly once. Such a walk iscalled an Eulerian walk.

I If G is Eulerian, each vertex must have an even degree.I This is a necessary condition, but is it sufficient?

Theorem

A graph G with no isolated vertices is Eulerian iff it isconnected and all its vertices have even degree.

Proof: ( =⇒ )I Suppose G is Eulerian: every vertex has even degree.

I each passage through a vertex uses two edges (in and out).I at the first vertex first edge is paired with last.

I Any two edges are in the same walk implies graph isconnected (unless it has isolated vertices).

9

Page 33: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Eulerian graphs

Definition

A graph is called Eulerian if it has a closed walk that containsall edges, and each edge occurs exactly once. Such a walk iscalled an Eulerian walk.

I If G is Eulerian, each vertex must have an even degree.I This is a necessary condition, but is it sufficient?

Theorem

A graph G with no isolated vertices is Eulerian iff it isconnected and all its vertices have even degree.

Proof:

( =⇒ )I Suppose G is Eulerian: every vertex has even degree.

I each passage through a vertex uses two edges (in and out).I at the first vertex first edge is paired with last.

I Any two edges are in the same walk implies graph isconnected (unless it has isolated vertices).

9

Page 34: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Eulerian graphs

Definition

A graph is called Eulerian if it has a closed walk that containsall edges, and each edge occurs exactly once. Such a walk iscalled an Eulerian walk.

I If G is Eulerian, each vertex must have an even degree.I This is a necessary condition, but is it sufficient?

Theorem

A graph G with no isolated vertices is Eulerian iff it isconnected and all its vertices have even degree.

Proof: ( =⇒ )I Suppose G is Eulerian: every vertex has even degree.

I each passage through a vertex uses two edges (in and out).I at the first vertex first edge is paired with last.

I Any two edges are in the same walk implies graph isconnected (unless it has isolated vertices).

9

Page 35: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Eulerian graphs

Definition

A graph is called Eulerian if it has a closed walk that containsall edges, and each edge occurs exactly once. Such a walk iscalled an Eulerian walk.

I If G is Eulerian, each vertex must have an even degree.I This is a necessary condition, but is it sufficient?

Theorem

A graph G with no isolated vertices is Eulerian iff it isconnected and all its vertices have even degree.

Proof: ( =⇒ )I Suppose G is Eulerian: every vertex has even degree.

I each passage through a vertex uses two edges (in and out).I at the first vertex first edge is paired with last.

I Any two edges are in the same walk implies graph isconnected (unless it has isolated vertices).

9

Page 36: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Maximal paths

I A path P is said to be maximal in G if it is not containedin any longer path.

I If a graph is finite, no path can extend forever, so maximal(non-extendible) paths exist.

I A maximum path is a path of maximum length among allpaths in the graph.Is every maximal path maximum?

v1

v2

v3 v4

I List all the maximal and maximum paths in the abovegraph.

10

Page 37: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Maximal paths

I A path P is said to be maximal in G if it is not containedin any longer path.

I If a graph is finite, no path can extend forever, so maximal(non-extendible) paths exist.

I A maximum path is a path of maximum length among allpaths in the graph.

Is every maximal path maximum?

v1

v2

v3 v4

I List all the maximal and maximum paths in the abovegraph.

10

Page 38: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Maximal paths

I A path P is said to be maximal in G if it is not containedin any longer path.

I If a graph is finite, no path can extend forever, so maximal(non-extendible) paths exist.

I A maximum path is a path of maximum length among allpaths in the graph.Is every maximal path maximum?

v1

v2

v3 v4

I List all the maximal and maximum paths in the abovegraph.

10

Page 39: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Maximal paths

I A path P is said to be maximal in G if it is not containedin any longer path.

I If a graph is finite, no path can extend forever, so maximal(non-extendible) paths exist.

I A maximum path is a path of maximum length among allpaths in the graph.Is every maximal path maximum?

v1

v2

v3 v4

I List all the maximal and maximum paths in the abovegraph.

10

Page 40: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Eulerian graphs

Lemma

If every vertex of a graph G has degree at least 2, then Gcontains a cycle.

11

Page 41: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Eulerian graphs

A path P is said to be maximal in G if it is not contained inany longer path. In a finite graph maximal paths exist.

Lemma

If every vertex of a graph G has degree at least 2, then Gcontains a cycle.

11

Page 42: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Eulerian graphs

A path P is said to be maximal in G if it is not contained inany longer path. In a finite graph maximal paths exist.

Lemma

If every vertex of a graph G has degree at least 2, then Gcontains a cycle.

Proof:

u v

I Let P be a maximal path in G. It starts from some u.

11

Page 43: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Eulerian graphs

A path P is said to be maximal in G if it is not contained inany longer path. In a finite graph maximal paths exist.

Lemma

If every vertex of a graph G has degree at least 2, then Gcontains a cycle.

Proof:

u v

I Let P be a maximal path in G. It starts from some u.

I Since P cannot be extended, every nbr of u is already in P .

11

Page 44: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Eulerian graphs

A path P is said to be maximal in G if it is not contained inany longer path. In a finite graph maximal paths exist.

Lemma

If every vertex of a graph G has degree at least 2, then Gcontains a cycle.

Proof:

u v

I Let P be a maximal path in G. It starts from some u.

I Since P cannot be extended, every nbr of u is already in P .

I As d(u) ≥ 2,∃v in P such that uv 6∈ P .

I Thus we have the cycle u . . . vu.

11

Page 45: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Eulerian graphs

A path P is said to be maximal in G if it is not contained inany longer path. In a finite graph maximal paths exist.

Lemma

If every vertex of a graph G has degree at least 2, then Gcontains a cycle.

Proof:u v

I Let P be a maximal path in G. It starts from some u.I Since P cannot be extended, every nbr of u is already in P .I As d(u) ≥ 2,∃v in P such that uv 6∈ P .I Thus we have the cycle u . . . vu.

Is this true if G were infinite?

No! Consider V = Z, E = {ij : |i− j| = 1}.−2 −1 0 1 2 3

· · ·· · ·

11

Page 46: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Eulerian graphs

Lemma

If every vertex of a graph G has degree at least 2, then Gcontains a cycle.

Proof:

u v

I Let P be a maximal path in G. It starts from some u.

I Since P cannot be extended, every nbr of u is already in P .

I As d(u) ≥ 2,∃v in P such that uv 6∈ P .

I Thus we have the cycle u . . . vu.

Is this true if G were infinite?No! Consider V = Z, E = {ij : |i− j| = 1}.

−2 −1 0 1 2 3

· · ·· · ·

11

Page 47: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Proof of theorem on Eulerian graphs

Lemma

If every vertex of a graph G has degree at least 2, then Gcontains a cycle.

Theorem

A graph G with no isolated vertices is Eulerian iff it isconnected and all its vertices have even degree.

12

Page 48: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Proof of theorem on Eulerian graphs

Lemma

If every vertex of a graph G has degree at least 2, then Gcontains a cycle.

Theorem

A graph G with no isolated vertices is Eulerian iff it isconnected and all its vertices have even degree.

Proof (⇐=): By induction on number of edges m.

I Base case: m = 1.

12

Page 49: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Proof of theorem on Eulerian graphs

Lemma

If every vertex of a graph G has degree at least 2, then Gcontains a cycle.

Theorem

A graph G with no isolated vertices is Eulerian iff it isconnected and all its vertices have even degree.

Proof (⇐=): By induction on number of edges m.

I Induction step: m > 1. By Lemma G has a cycle C.

12

Page 50: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Proof of theorem on Eulerian graphs

Lemma

If every vertex of a graph G has degree at least 2, then Gcontains a cycle.

Theorem

A graph G with no isolated vertices is Eulerian iff it isconnected and all its vertices have even degree.

Proof (⇐=): By induction on number of edges m.

I Induction step: m > 1. By Lemma G has a cycle C.I Delete all edges in cycle C and (new) isolated vertices.

12

Page 51: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Proof of theorem on Eulerian graphs

Lemma

If every vertex of a graph G has degree at least 2, then Gcontains a cycle.

Theorem

A graph G with no isolated vertices is Eulerian iff it isconnected and all its vertices have even degree.

Proof (⇐=): By induction on number of edges m.

I Induction step: m > 1. By Lemma G has a cycle C.I Delete all edges in cycle C and (new) isolated vertices.I Get G1, . . . , Gk. Each Gi is

I connectedI has < m edges.I all its vertices have even degree (why? )

12

Page 52: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Proof of theorem on Eulerian graphs

Lemma

If every vertex of a graph G has degree at least 2, then Gcontains a cycle.

Theorem

A graph G with no isolated vertices is Eulerian iff it isconnected and all its vertices have even degree.

Proof (⇐=): By induction on number of edges m.

I Induction step: m > 1. By Lemma G has a cycle C.I Delete all edges in cycle C and (new) isolated vertices.I Get G1, . . . , Gk. Each Gi is

I connectedI has < m edges.I all its vertices have even degree (why? – degree of any

vertex was even and removing C, reduces each vertexdegree by 0 or 2.)

12

Page 53: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Proof of theorem on Eulerian graphs

Lemma

If every vertex of a graph G has degree at least 2, then Gcontains a cycle.

Theorem

A graph G with no isolated vertices is Eulerian iff it isconnected and all its vertices have even degree.

Proof (⇐=): By induction on number of edges m.

I Induction step: m > 1. By Lemma G has a cycle C.I Delete all edges in cycle C and (new) isolated vertices.I By indn hyp, each Gi is Eulerian, has a Eulerian walk.

12

Page 54: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Proof of theorem on Eulerian graphs

Lemma

If every vertex of a graph G has degree at least 2, then Gcontains a cycle.

Theorem

A graph G with no isolated vertices is Eulerian iff it isconnected and all its vertices have even degree.

Proof (⇐=): By induction on number of edges m.

I Induction step: m > 1. By Lemma G has a cycle C.I Delete all edges in cycle C and (new) isolated vertices.I By indn hyp, each Gi is Eulerian, has a Eulerian walk.I Combine the cycle C and the Eulerian walk of G1, . . . , Gk

to produce an Eulerian walk of G (how?).

12

Page 55: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Proof of theorem on Eulerian graphs

Lemma

If every vertex of a graph G has degree at least 2, then Gcontains a cycle.

Theorem

A graph G with no isolated vertices is Eulerian iff it isconnected and all its vertices have even degree.

Proof (⇐=): By induction on number of edges m.I Induction step: m > 1. By Lemma G has a cycle C.

I Delete all edges in cycle C and (new) isolated vertices.I By indn hyp, each Gi is Eulerian, has a Eulerian walk.I Combine the cycle C and the Eulerian walk of G1, . . . , Gk

to produce an Eulerian walk of G (how?).I Traverse along cycle C in G and when some Gi is entered

for first time, detour along an Eulerian walk of Gi.I This walk ends at vertex where we started detour.I When we complete traversal of C in this way, we have

completed an Eulerian walk on G.12

Page 56: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Principle of extremality

Principle of extremality

I In proving the lemma we used a “new” important prooftechnique, called extremality.

I By considering some “extreme” structure, we got someadditional information which we used in the proof.

I E.g., Above, since a maximal path could not be extended,we got that every neighbour of an endpoint of P is in P .

I (H.W) Can you show the theorem directly fromextremality without using induction?

13

Page 57: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Principle of extremality

Principle of extremality

I In proving the lemma we used a “new” important prooftechnique, called extremality.

I By considering some “extreme” structure, we got someadditional information which we used in the proof.

I E.g., Above, since a maximal path could not be extended,we got that every neighbour of an endpoint of P is in P .

I (H.W) Can you show the theorem directly fromextremality without using induction?

13

Page 58: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Principle of extremality

Principle of extremality

I In proving the lemma we used a “new” important prooftechnique, called extremality.

I By considering some “extreme” structure, we got someadditional information which we used in the proof.

I E.g., Above, since a maximal path could not be extended,we got that every neighbour of an endpoint of P is in P .

I (H.W) Can you show the theorem directly fromextremality without using induction?

13

Page 59: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Principle of extremality

Principle of extremality

I In proving the lemma we used a “new” important prooftechnique, called extremality.

I By considering some “extreme” structure, we got someadditional information which we used in the proof.

I E.g., Above, since a maximal path could not be extended,we got that every neighbour of an endpoint of P is in P .

I (H.W) Can you show the theorem directly fromextremality without using induction?

13

Page 60: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Applications of Eulerian graphs

Corollary

Every graph with all vertices having even degree decomposesinto cycles

Proof: (H.W) or read from Douglas West’s book!

An interesting application of Eulerian graphs

If we want to draw a given connected graph G on paper, howmany times must we stop and move the pen? No segmentshould be drawn twice.

14

Page 61: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Applications of Eulerian graphs

Corollary

Every graph with all vertices having even degree decomposesinto cycles

Proof: (H.W) or read from Douglas West’s book!

An interesting application of Eulerian graphs

If we want to draw a given connected graph G on paper, howmany times must we stop and move the pen? No segmentshould be drawn twice.

14

Page 62: CS 207m 2018: Discrete Structures (Minor)akshayss/courses/cs207m-2018/... · 2018. 3. 8. · Topic 3: Graph theory Textbook Reference I Introduction to Graph Theory, 2nd Ed., by Douglas

Applications of Eulerian graphs

Corollary

Every graph with all vertices having even degree decomposesinto cycles

Proof: (H.W) or read from Douglas West’s book!

An interesting application of Eulerian graphs

If we want to draw a given connected graph G on paper, howmany times must we stop and move the pen? No segmentshould be drawn twice.

14