Graphs Reading: EC 7.17.2 Peter J. Haas INFO 150 Fall Semester - - PowerPoint PPT Presentation

graphs
SMART_READER_LITE
LIVE PREVIEW

Graphs Reading: EC 7.17.2 Peter J. Haas INFO 150 Fall Semester - - PowerPoint PPT Presentation

Graphs Reading: EC 7.17.2 Peter J. Haas INFO 150 Fall Semester 2019 Lecture 15 1/ 21 Graphs Introduction The K onigsberg Bridge Problem Definitions and Terminology Graph Notation for K onigsberg Problem Eulerian Graphs Graphs


slide-1
SLIDE 1

Graphs

Reading: EC 7.1–7.2 Peter J. Haas INFO 150 Fall Semester 2019

Lecture 15 1/ 21

slide-2
SLIDE 2

Graphs Introduction The K¨

  • nigsberg Bridge Problem

Definitions and Terminology Graph Notation for K¨

  • nigsberg Problem

Eulerian Graphs Graphs with Eulerian Trails Proofs About Graphs

Lecture 15 2/ 21

slide-3
SLIDE 3

Introduction

You have already seen lots of graphs—we will now study their abstract properties

Lecture 15 3/ 21

2 3 4 a b c d 1 b c d 1 2 3 4 a

Directed graph

H H H H H H H T T T T HHH HHT HTH HTT THH HHT TTH TTT T T T

Tree

HS Friends College Friends Girlfriend's Friends University Friends

Other Academic Friends griffsgraphs.wordpress.com/2012/07/02/a-facebook-network/

Facebook network Watson drug discovery

slide-4
SLIDE 4

Origins and Euler

  • nigsberg bridge problem

I Consider a walk around town: A, 6, B, 5, D, 4, A I Eulerian trail: Crosses each bridge once I Eulerian circuit: ... and comes back to starting point I Does there exist an Eulerian circuit?

Lecture 15 4/ 21

7 bridges of K¨

  • nigsberg

A B C D

Abstract 7 bridges of K¨

  • nigsberg

A B C D

1 2 3 4 5 6 7 K¨

  • nigsberg graph
slide-5
SLIDE 5

Origins and Euler

  • nigsberg bridge problem

I Consider a walk around town: A, 6, B, 5, D, 4, A I Eulerian trail: Crosses each bridge once I Eulerian circuit: ... and comes back to starting point I Does there exist an Eulerian circuit? Euler’s non-existence proof I Suppose A is an intermediate vertex (not starting or ending) I Bridges to A must come in pairs I So need an even number of edges I But every vertex has an odd number of edges I Hence none of the four regions can be an interior vertex I So Eulerian trail cannot exist

Lecture 15 4/ 21

7 bridges of K¨

  • nigsberg

A B C D

Abstract 7 bridges of K¨

  • nigsberg

A B C D

1 2 3 4 5 6 7 K¨

  • nigsberg graph
slide-6
SLIDE 6

Eulerian Trails

Proposition 1 In any graph, if there are an odd number of edges connected to a vertex x, then x cannot be an interior vertex of an Eulerian trail. Example: Explain why the following graph does not have an Eulerian trail

a b c d e f g h i j

Question: Can we give conditions under which there exists an Eulerian trail?

Lecture 15 5/ 21

vertices

gf

,

h

, j

have odd # OP

edges

slide-7
SLIDE 7

Definitions and Terminology

Definitions

  • 1. A graph G consists of a set E of edges and a set V of vertices (also called nodes).

I An edge is associated with one or two vertices, called endpoints. I Two nodes joined by an edge are called adjacent nodes. I An edge with one vertex is called a loop. I Two edges having the same endpoints are called multiple edges or parallel edges.

  • 2. A walk is a sequence v1e1v2e2 · · · vnenvn+1 of alternating vertices and edges.

I Each edge in the list lies between its endpoints. I If beginning and end vertices are the same, the walk is closed. I The length of a walk is the number of edges (n in the above example). I A walk of length 0 is called a trivial walk.

  • 3. A trail is a walk with no repeated edges; a path is a walk with no repeated vertices.

I A circuit is a closed trail I A circuit having one vertex and no edges is called a trivial circuit. I A trail or circuit is Eulerian if it uses every edge in the graph. I A cycle is a nontrivial circuit in which the only repeated node is the first/last one. Lecture 15 6/ 21

a. t.DE

!

slide-8
SLIDE 8

Definitions: Example

A B C 1 2 3 4 5

  • 1. The graph has 3 nodes and 5 edges
  • 2. Edge 1 is a loop; edges 3 and 4 are parallel
  • 3. Some walks in the graph:

(a) B, 5, C, 5, B, 2, A, 2, B is a closed walk that repeats edge 5 (so not a trail) (b) A, 2, B, 5, C is a path (no repeated vertices) (c) B is a trivial walk and a trivial circuit (d) A, 1, A, 2, B, 5, C, 3, A is a circuit starting and ending at A (e) A, 2, B, 5, C, 3, A, 1, A, 4, C is an Eulerian trail (f) The first part of (e), A, 2, B, 5, C, 3, A, is a cycle—unlike (d), node A appears

  • nly twice

Challenge: Add one edge to the graph to create an Eulerian circuit

Lecture 15 7/ 21

?

slide-9
SLIDE 9

Graphs in Applications

The graph that you use depends upon the application

Madrid Rome London Paris Madrid Rome London Paris

702 812 31 3913 17 271 1703 2321 117 3421

G1: Simple Graph G2: Directed Graph with Parallel Edges

Flight planning I How do I get from Madrid to London? (G1 or G2)

I Note: For G1, it suffices just to list the sequence of vertices

I What flights will take me from Madrid to London? (G2)

Lecture 15 8/ 21

slide-10
SLIDE 10

More Graph Notation

Definitions

  • 1. A simple graph is a graph with no loops and no multiple (i.e., parallel) edges.
  • 2. Notation [a, b]: an undirected edge with endpoints a and b
  • 3. Notation (a, b): an directed edge going from a to b

Madrid Rome London Paris Madrid Rome London Paris

702 812 31 3913 17 271 1703 2321 117 3421

G1: Simple Graph G2: Directed Graph with Parallel Edges

Examples I G1 edges are: [Madrid, Paris], [London, Paris], [Madrid, Rome], [Paris, Rome] I G2 directed edges include: (Rome, Paris), (Paris, Rome), (Rome, Madrid) I Note: There is never any ambiguity in a simple graph

Lecture 15 9/ 21

slide-11
SLIDE 11

Graph Notation for K¨

  • nigsberg Problem

Definitions

  • 1. An edge e is incident with a node v if and only if v is an endpoint of e
  • 2. The degree of node v, denoted deg(v), is the number of times v appears as the

endpoint of an edge. (It equals the number of edges that are incident with v, except that loops are counted twice.)

  • 3. A graph G is connected if there is a walk between any two nodes.
  • 4. A graph H is is a subgraph of a graph G if all nodes and edges in H are also

nodes and edges in G.

  • 5. A connected component of a graph G is a connected subgraph H of G such

that no other connected subgraph of G containing H exists.

Lecture 15 10/ 21

e-

  • v

If

slide-12
SLIDE 12

Graph Notation for K¨

  • nigsberg Problem

Definitions

  • 1. An edge e is incident with a node v if and only if v is an endpoint of e
  • 2. The degree of node v, denoted deg(v), is the number of times v appears as the

endpoint of an edge. (It equals the number of edges that are incident with v, except that loops are counted twice.)

  • 3. A graph G is connected if there is a walk between any two nodes.
  • 4. A graph H is is a subgraph of a graph G if all nodes and edges in H are also

nodes and edges in G.

  • 5. A connected component of a graph G is a connected subgraph H of G such

that no other connected subgraph of G containing H exists. Example I The degree of node 3 is 4: it appears in [1, 3], [3, 2], [5, 3], and [3, 4]. The degree of node 6 is 3 I There is no walk from node 4 to node 6, so the graph is not connected I The graph has two connected components

Lecture 15 10/ 21

1 2 3 4 5 6 7 8

slide-13
SLIDE 13

  • nigsberg Graph Notation: Example

Definitions

  • 1. An edge e is incident with a node v if and only if v is an endpoint of e
  • 2. The degree of node v, denoted deg(v), is the number of times v appears as the

endpoint of an edge. (It equals the number of edges that are incident with v, except that loops are counted twice.)

  • 3. A graph G is connected if there is a walk between any two nodes.
  • 4. A graph H is is a subgraph of a graph G if all nodes and edges in H are also

nodes and edges in G.

  • 5. A connected component of a graph G is a connected subgraph H of G such

that no other connected subgraph of G containing H exists. Example I What is the degree of node 1? I Find an Eulerian trail in the component on the right I Find an Eulerian circuit in the component on the left I Is the red subgraph a connected component?

Lecture 15 11/ 21

1 2 3 4 5 6 7 8

.

÷ :

"

slide-14
SLIDE 14

Eulerian Graphs

Definition A graph G is Eulerian if it contains an Eulerian circuit. Theorem 2 Let G be a connected graph. The graph G is Eulerian if and only if every node in G has even degree. The proof of this theorem uses induction. The basic ideas are illustrated in the next

  • example. We reduce the problem of finding an Eulerian circuit in a big graph to

finding Eulerian circuits in several smaller graphs.

Lecture 15 12/ 21

slide-15
SLIDE 15

How to Find an Eulerian Circuit

Given a connected graph G with all nodes of even degree:

  • 1. Find any circuit C and form a graph G 0 by removing from G all edges in the

circuit C

Lecture 15 13/ 21

7 3 4 5 6 8 9 10 14 12 13 11 7 1 2 3 4 5 6 8 9 10 14 12 13 11 7 1 2 3 8 14 11

slide-16
SLIDE 16

How to Find an Eulerian Circuit

Given a connected graph G with all nodes of even degree:

  • 1. Find any circuit C and form a graph G 0 by removing from G all edges in the

circuit C

  • 2. Observe that G 0 is not connected; call its components H1 and H2

Lecture 15 13/ 21

7 3 4 5 6 8 9 10 14 12 13 11 7 1 2 3 4 5 6 8 9 10 14 12 13 11 7 1 2 3 8 14 11

for

slide-17
SLIDE 17

How to Find an Eulerian Circuit

Given a connected graph G with all nodes of even degree:

  • 1. Find any circuit C and form a graph G 0 by removing from G all edges in the

circuit C

  • 2. Observe that G 0 is not connected; call its components H1 and H2
  • 3. H1 and H2 are smaller connected graphs, with all nodes having even degree

(a) H1 has an Eulerian circuit C1 = 3, 4, 5, 6, 7, 11, 12, 13, 6, 3, 11, 13, 14, 3 (b) H2 has an Eulerian circuit C2 = 8, 9, 10, 8

Lecture 15 13/ 21

7 3 4 5 6 8 9 10 14 12 13 11 7 1 2 3 4 5 6 8 9 10 14 12 13 11 7 1 2 3 8 14 11

slide-18
SLIDE 18

How to Find an Eulerian Circuit

Given a connected graph G with all nodes of even degree:

  • 1. Find any circuit C and form a graph G 0 by removing from G all edges in the

circuit C

  • 2. Observe that G 0 is not connected; call its components H1 and H2
  • 3. H1 and H2 are smaller connected graphs, with all nodes having even degree

(a) H1 has an Eulerian circuit C1 = 3, 4, 5, 6, 7, 11, 12, 13, 6, 3, 11, 13, 14, 3 (b) H2 has an Eulerian circuit C2 = 8, 9, 10, 8

  • 4. Piece together C, C1, and C2 to get the Eulerian circuit:

I In C, replace 3 with C1 and 8 with C2:

1, 2, 3, 4, 5, 6, 7, 11, 12, 13, 6, 3, 11, 13, 14, 3 | {z }, 7, 8, 9, 10, 8 | {z }, 11, 14, 1

Lecture 15 13/ 21

7 3 4 5 6 8 9 10 14 12 13 11 7 1 2 3 4 5 6 8 9 10 14 12 13 11 7 1 2 3 8 14 11

slide-19
SLIDE 19

How to Find an Eulerian Circuit

Given a connected graph G with all nodes of even degree:

  • 1. Find any circuit C and form a graph G 0 by removing from G all edges in the

circuit C

  • 2. Observe that G 0 is not connected; call its components H1 and H2
  • 3. H1 and H2 are smaller connected graphs, with all nodes having even degree

(a) H1 has an Eulerian circuit C1 = 3, 4, 5, 6, 7, 11, 12, 13, 6, 3, 11, 13, 14, 3 (b) H2 has an Eulerian circuit C2 = 8, 9, 10, 8

  • 4. Piece together C, C1, and C2 to get the Eulerian circuit:

I In C, replace 3 with C1 and 8 with C2:

1, 2, 3, 4, 5, 6, 7, 11, 12, 13, 6, 3, 11, 13, 14, 3 | {z }, 7, 8, 9, 10, 8 | {z }, 11, 14, 1

Lecture 15 13/ 21

7 3 4 5 6 8 9 10 14 12 13 11 7 1 2 3 4 5 6 8 9 10 14 12 13 11 7 1 2 3 8 14 11

We can apply this idea recursively!

slide-20
SLIDE 20

Graphs with Eulerian Trails

4 5 6 1 2 3

Can you draw the figure without lifting pencil from paper or retracing a line? I Same as asking: Can you find an Eulerian trail? I We are not asking if graph is Eulerian (we’re not trying to find a circuit)

Lecture 15 14/ 21

slide-21
SLIDE 21

Two Simple Facts About Graphs

Theorem 3 In any graph, the sum of the degrees of the vertices is equal to twice the number of

  • edges. I.e., Pn

i=1 deg(vi) = 2m, where v1, v2, . . . , vn are the vertices and m is the

number of edges.

Lecture 15 15/ 21

slide-22
SLIDE 22

Two Simple Facts About Graphs

Theorem 3 In any graph, the sum of the degrees of the vertices is equal to twice the number of

  • edges. I.e., Pn

i=1 deg(vi) = 2m, where v1, v2, . . . , vn are the vertices and m is the

number of edges. Proof: I Each edge has two end points (not necessarily distinct) I Degree of a node counts # of times it appears as endpoint of an edge I So when summing the degrees of nodes, we count each edge exactly twice

Lecture 15 15/ 21

slide-23
SLIDE 23

Two Simple Facts About Graphs

Theorem 3 In any graph, the sum of the degrees of the vertices is equal to twice the number of

  • edges. I.e., Pn

i=1 deg(vi) = 2m, where v1, v2, . . . , vn are the vertices and m is the

number of edges. Proof: I Each edge has two end points (not necessarily distinct) I Degree of a node counts # of times it appears as endpoint of an edge I So when summing the degrees of nodes, we count each edge exactly twice Corollary 4 In any graph, the number of nodes with odd degree is even.

Lecture 15 15/ 21

slide-24
SLIDE 24

Two Simple Facts About Graphs

Theorem 3 In any graph, the sum of the degrees of the vertices is equal to twice the number of

  • edges. I.e., Pn

i=1 deg(vi) = 2m, where v1, v2, . . . , vn are the vertices and m is the

number of edges. Proof: I Each edge has two end points (not necessarily distinct) I Degree of a node counts # of times it appears as endpoint of an edge I So when summing the degrees of nodes, we count each edge exactly twice Corollary 4 In any graph, the number of nodes with odd degree is even. Proof: I The sum of two evens is even, sum of two odds is even, sum of even and odd is odd I When calculating sum of all node degrees, the even numbers sum to an even number I By Theorem 3, all the numbers sum to an even number I Therefore, the odd numbers sum to an even number I Therefore, there must be an even number of these

Lecture 15 15/ 21

slide-25
SLIDE 25

General Solution for Eulerian Trails

Theorem 5 A connected, non-Eulerian graph G has an Eulerian trail if and only if G has exactly two nodes of odd degree. The train must begin and end at these nodes.

Lecture 15 16/ 21

4 5 6 1 2 3 C = 3, 2, 1, 5, 4, 6, 2, 5, 6, 3, 4, 3 T = 3, 2, 1, 5, 4, 6, 2, 5, 6, 3, 4

slide-26
SLIDE 26

General Solution for Eulerian Trails

Theorem 5 A connected, non-Eulerian graph G has an Eulerian trail if and only if G has exactly two nodes of odd degree. The train must begin and end at these nodes. Proof: I Suppose that G is a connected graph that is not Eulerian but has an Eulerian trail from v to w

Lecture 15 16/ 21

4 5 6 1 2 3 C = 3, 2, 1, 5, 4, 6, 2, 5, 6, 3, 4, 3 T = 3, 2, 1, 5, 4, 6, 2, 5, 6, 3, 4

slide-27
SLIDE 27

General Solution for Eulerian Trails

Theorem 5 A connected, non-Eulerian graph G has an Eulerian trail if and only if G has exactly two nodes of odd degree. The train must begin and end at these nodes. Proof: I Suppose that G is a connected graph that is not Eulerian but has an Eulerian trail from v to w

I By Proposition 1, every node (except maybe v and w) has even degree Lecture 15 16/ 21

4 5 6 1 2 3 C = 3, 2, 1, 5, 4, 6, 2, 5, 6, 3, 4, 3 T = 3, 2, 1, 5, 4, 6, 2, 5, 6, 3, 4

slide-28
SLIDE 28

General Solution for Eulerian Trails

Theorem 5 A connected, non-Eulerian graph G has an Eulerian trail if and only if G has exactly two nodes of odd degree. The train must begin and end at these nodes. Proof: I Suppose that G is a connected graph that is not Eulerian but has an Eulerian trail from v to w

I By Proposition 1, every node (except maybe v and w) has even degree I Since graph is non-Eulerian, at least one node has odd degree (Theorem 2) Lecture 15 16/ 21

4 5 6 1 2 3 C = 3, 2, 1, 5, 4, 6, 2, 5, 6, 3, 4, 3 T = 3, 2, 1, 5, 4, 6, 2, 5, 6, 3, 4

slide-29
SLIDE 29

General Solution for Eulerian Trails

Theorem 5 A connected, non-Eulerian graph G has an Eulerian trail if and only if G has exactly two nodes of odd degree. The train must begin and end at these nodes. Proof: I Suppose that G is a connected graph that is not Eulerian but has an Eulerian trail from v to w

I By Proposition 1, every node (except maybe v and w) has even degree I Since graph is non-Eulerian, at least one node has odd degree (Theorem 2) I Therefore, at least two nodes have odd degree (Corollary 4) Lecture 15 16/ 21

4 5 6 1 2 3 C = 3, 2, 1, 5, 4, 6, 2, 5, 6, 3, 4, 3 T = 3, 2, 1, 5, 4, 6, 2, 5, 6, 3, 4

slide-30
SLIDE 30

General Solution for Eulerian Trails

Theorem 5 A connected, non-Eulerian graph G has an Eulerian trail if and only if G has exactly two nodes of odd degree. The train must begin and end at these nodes. Proof: I Suppose that G is a connected graph that is not Eulerian but has an Eulerian trail from v to w

I By Proposition 1, every node (except maybe v and w) has even degree I Since graph is non-Eulerian, at least one node has odd degree (Theorem 2) I Therefore, at least two nodes have odd degree (Corollary 4) I These nodes must be v and w Lecture 15 16/ 21

4 5 6 1 2 3 C = 3, 2, 1, 5, 4, 6, 2, 5, 6, 3, 4, 3 T = 3, 2, 1, 5, 4, 6, 2, 5, 6, 3, 4

slide-31
SLIDE 31

General Solution for Eulerian Trails

Theorem 5 A connected, non-Eulerian graph G has an Eulerian trail if and only if G has exactly two nodes of odd degree. The train must begin and end at these nodes. Proof: I Suppose that G is a connected graph that is not Eulerian but has an Eulerian trail from v to w

I By Proposition 1, every node (except maybe v and w) has even degree I Since graph is non-Eulerian, at least one node has odd degree (Theorem 2) I Therefore, at least two nodes have odd degree (Corollary 4) I These nodes must be v and w

I Now suppose that G is a connected graph with exactly two nodes, x and y, of odd degree

Lecture 15 16/ 21

4 5 6 1 2 3 C = 3, 2, 1, 5, 4, 6, 2, 5, 6, 3, 4, 3 T = 3, 2, 1, 5, 4, 6, 2, 5, 6, 3, 4

slide-32
SLIDE 32

General Solution for Eulerian Trails

Theorem 5 A connected, non-Eulerian graph G has an Eulerian trail if and only if G has exactly two nodes of odd degree. The train must begin and end at these nodes. Proof: I Suppose that G is a connected graph that is not Eulerian but has an Eulerian trail from v to w

I By Proposition 1, every node (except maybe v and w) has even degree I Since graph is non-Eulerian, at least one node has odd degree (Theorem 2) I Therefore, at least two nodes have odd degree (Corollary 4) I These nodes must be v and w

I Now suppose that G is a connected graph with exactly two nodes, x and y, of odd degree

I Form G 0 by adding the edge [x, y] to G Lecture 15 16/ 21

4 5 6 1 2 3 C = 3, 2, 1, 5, 4, 6, 2, 5, 6, 3, 4, 3 T = 3, 2, 1, 5, 4, 6, 2, 5, 6, 3, 4

slide-33
SLIDE 33

General Solution for Eulerian Trails

Theorem 5 A connected, non-Eulerian graph G has an Eulerian trail if and only if G has exactly two nodes of odd degree. The train must begin and end at these nodes. Proof: I Suppose that G is a connected graph that is not Eulerian but has an Eulerian trail from v to w

I By Proposition 1, every node (except maybe v and w) has even degree I Since graph is non-Eulerian, at least one node has odd degree (Theorem 2) I Therefore, at least two nodes have odd degree (Corollary 4) I These nodes must be v and w

I Now suppose that G is a connected graph with exactly two nodes, x and y, of odd degree

I Form G 0 by adding the edge [x, y] to G I All nodes in G 0 have even degree, so G 0 has an Eulerian circuit (Theorem 2) Lecture 15 16/ 21

4 5 6 1 2 3 C = 3, 2, 1, 5, 4, 6, 2, 5, 6, 3, 4, 3 T = 3, 2, 1, 5, 4, 6, 2, 5, 6, 3, 4

slide-34
SLIDE 34

General Solution for Eulerian Trails

Theorem 5 A connected, non-Eulerian graph G has an Eulerian trail if and only if G has exactly two nodes of odd degree. The train must begin and end at these nodes. Proof: I Suppose that G is a connected graph that is not Eulerian but has an Eulerian trail from v to w

I By Proposition 1, every node (except maybe v and w) has even degree I Since graph is non-Eulerian, at least one node has odd degree (Theorem 2) I Therefore, at least two nodes have odd degree (Corollary 4) I These nodes must be v and w

I Now suppose that G is a connected graph with exactly two nodes, x and y, of odd degree

I Form G 0 by adding the edge [x, y] to G I All nodes in G 0 have even degree, so G 0 has an Eulerian circuit (Theorem 2) I Deleting edge [x, y] from the circuit gives an Eulerian trail in G from x to y Lecture 15 16/ 21

4 5 6 1 2 3 C = 3, 2, 1, 5, 4, 6, 2, 5, 6, 3, 4, 3 T = 3, 2, 1, 5, 4, 6, 2, 5, 6, 3, 4

slide-35
SLIDE 35

Proofs about Graphs

We will look at two example proofs I A direct proof I An inductive proof of Theorem 2 We will use the techniques that we have learned, but in a new, slightly more complicated context

Lecture 15 17/ 21

slide-36
SLIDE 36

A Result on Cycles and Vertices

Proposition 4 For every connected graph G with at least one edge, if G has no cycles, then G has at least one vertex of degree 1.

Lecture 15 18/ 21

slide-37
SLIDE 37

The Contrapositive Result

Proposition 40 (Contrapositive) For every connected graph G with at least one edge, if every vertex is of degree at least 2, then G has a cycle. Proof I Let G be a connected graph with at least one edge and every vertex of degree ≥ 2. Let n be the number of vertices in G, and choose v0 to be any vertex in G.

Lecture 15 19/ 21

slide-38
SLIDE 38

The Contrapositive Result

Proposition 40 (Contrapositive) For every connected graph G with at least one edge, if every vertex is of degree at least 2, then G has a cycle. Proof I Let G be a connected graph with at least one edge and every vertex of degree ≥ 2. Let n be the number of vertices in G, and choose v0 to be any vertex in G. I Choose vertices to build a walk:

Lecture 15 19/ 21

slide-39
SLIDE 39

The Contrapositive Result

Proposition 40 (Contrapositive) For every connected graph G with at least one edge, if every vertex is of degree at least 2, then G has a cycle. Proof I Let G be a connected graph with at least one edge and every vertex of degree ≥ 2. Let n be the number of vertices in G, and choose v0 to be any vertex in G. I Choose vertices to build a walk:

I Since v0 has degree ≥ 2, we can pick v1 to be the other endpoint of an

edge incident with v0.

Lecture 15 19/ 21

slide-40
SLIDE 40

The Contrapositive Result

Proposition 40 (Contrapositive) For every connected graph G with at least one edge, if every vertex is of degree at least 2, then G has a cycle. Proof I Let G be a connected graph with at least one edge and every vertex of degree ≥ 2. Let n be the number of vertices in G, and choose v0 to be any vertex in G. I Choose vertices to build a walk:

I Since v0 has degree ≥ 2, we can pick v1 to be the other endpoint of an

edge incident with v0.

I Since v1 has degree ≥ 2, we can pick v2 to be the other endpoint of an

edge incident with v1 other than [v0, v1].

Lecture 15 19/ 21

slide-41
SLIDE 41

The Contrapositive Result

Proposition 40 (Contrapositive) For every connected graph G with at least one edge, if every vertex is of degree at least 2, then G has a cycle. Proof I Let G be a connected graph with at least one edge and every vertex of degree ≥ 2. Let n be the number of vertices in G, and choose v0 to be any vertex in G. I Choose vertices to build a walk:

I Since v0 has degree ≥ 2, we can pick v1 to be the other endpoint of an

edge incident with v0.

I Since v1 has degree ≥ 2, we can pick v2 to be the other endpoint of an

edge incident with v1 other than [v0, v1].

I Since v2 has degree ≥ 2, we can pick v3 to be the other endpoint of an

edge incident with v2 other than [v1, v2].

Lecture 15 19/ 21

slide-42
SLIDE 42

The Contrapositive Result

Proposition 40 (Contrapositive) For every connected graph G with at least one edge, if every vertex is of degree at least 2, then G has a cycle. Proof I Let G be a connected graph with at least one edge and every vertex of degree ≥ 2. Let n be the number of vertices in G, and choose v0 to be any vertex in G. I Choose vertices to build a walk:

I Since v0 has degree ≥ 2, we can pick v1 to be the other endpoint of an

edge incident with v0.

I Since v1 has degree ≥ 2, we can pick v2 to be the other endpoint of an

edge incident with v1 other than [v0, v1].

I Since v2 has degree ≥ 2, we can pick v3 to be the other endpoint of an

edge incident with v2 other than [v1, v2].

I ...and so on, until vertex vn has been chosen. Lecture 15 19/ 21

slide-43
SLIDE 43

The Contrapositive Result

Proposition 40 (Contrapositive) For every connected graph G with at least one edge, if every vertex is of degree at least 2, then G has a cycle. Proof I Let G be a connected graph with at least one edge and every vertex of degree ≥ 2. Let n be the number of vertices in G, and choose v0 to be any vertex in G. I Choose vertices to build a walk:

I Since v0 has degree ≥ 2, we can pick v1 to be the other endpoint of an

edge incident with v0.

I Since v1 has degree ≥ 2, we can pick v2 to be the other endpoint of an

edge incident with v1 other than [v0, v1].

I Since v2 has degree ≥ 2, we can pick v3 to be the other endpoint of an

edge incident with v2 other than [v1, v2].

I ...and so on, until vertex vn has been chosen.

I This walk uses n + 1 vertices, but G only has n vertices, so there must be a first value j such that vi = vj for some i < j. (The “pigeonhole principle”.)

Lecture 15 19/ 21

slide-44
SLIDE 44

The Contrapositive Result

Proposition 40 (Contrapositive) For every connected graph G with at least one edge, if every vertex is of degree at least 2, then G has a cycle. Proof I Let G be a connected graph with at least one edge and every vertex of degree ≥ 2. Let n be the number of vertices in G, and choose v0 to be any vertex in G. I Choose vertices to build a walk:

I Since v0 has degree ≥ 2, we can pick v1 to be the other endpoint of an

edge incident with v0.

I Since v1 has degree ≥ 2, we can pick v2 to be the other endpoint of an

edge incident with v1 other than [v0, v1].

I Since v2 has degree ≥ 2, we can pick v3 to be the other endpoint of an

edge incident with v2 other than [v1, v2].

I ...and so on, until vertex vn has been chosen.

I This walk uses n + 1 vertices, but G only has n vertices, so there must be a first value j such that vi = vj for some i < j. (The “pigeonhole principle”.) I The cycle is then C = vi, vi+1, vi+2, . . . , vj.

Lecture 15 19/ 21

slide-45
SLIDE 45

Inductive Proof of Theorem 2

Theorem 2 Let G be a connected graph with at least one edge. The graph G is Eulerian if and

  • nly if every node in G has even degree.

Lecture 15 20/ 21

slide-46
SLIDE 46

Inductive Proof of Theorem 2

Theorem 2 Let G be a connected graph with at least one edge. The graph G is Eulerian if and

  • nly if every node in G has even degree.
  • 1. If G is Eulerian, then every node has even degree

Lecture 15 20/ 21

slide-47
SLIDE 47

Inductive Proof of Theorem 2

Theorem 2 Let G be a connected graph with at least one edge. The graph G is Eulerian if and

  • nly if every node in G has even degree.
  • 1. If G is Eulerian, then every node has even degree

I Suppose G has an Eulerian circuit, and let x be any node in the graph Lecture 15 20/ 21

slide-48
SLIDE 48

Inductive Proof of Theorem 2

Theorem 2 Let G be a connected graph with at least one edge. The graph G is Eulerian if and

  • nly if every node in G has even degree.
  • 1. If G is Eulerian, then every node has even degree

I Suppose G has an Eulerian circuit, and let x be any node in the graph I Write the Eulerian circuit as a walk v1e1v2e2 · · · vnenv1 Lecture 15 20/ 21

slide-49
SLIDE 49

Inductive Proof of Theorem 2

Theorem 2 Let G be a connected graph with at least one edge. The graph G is Eulerian if and

  • nly if every node in G has even degree.
  • 1. If G is Eulerian, then every node has even degree

I Suppose G has an Eulerian circuit, and let x be any node in the graph I Write the Eulerian circuit as a walk v1e1v2e2 · · · vnenv1 I Since G is connected, x must be one of the vertices in the walk Lecture 15 20/ 21

slide-50
SLIDE 50

Inductive Proof of Theorem 2

Theorem 2 Let G be a connected graph with at least one edge. The graph G is Eulerian if and

  • nly if every node in G has even degree.
  • 1. If G is Eulerian, then every node has even degree

I Suppose G has an Eulerian circuit, and let x be any node in the graph I Write the Eulerian circuit as a walk v1e1v2e2 · · · vnenv1 I Since G is connected, x must be one of the vertices in the walk I Each time (if any) that x appears in the middle of the walk, it is the endpoint for

two different edges

Lecture 15 20/ 21

slide-51
SLIDE 51

Inductive Proof of Theorem 2

Theorem 2 Let G be a connected graph with at least one edge. The graph G is Eulerian if and

  • nly if every node in G has even degree.
  • 1. If G is Eulerian, then every node has even degree

I Suppose G has an Eulerian circuit, and let x be any node in the graph I Write the Eulerian circuit as a walk v1e1v2e2 · · · vnenv1 I Since G is connected, x must be one of the vertices in the walk I Each time (if any) that x appears in the middle of the walk, it is the endpoint for

two different edges

I If x = v1, then it is the endpoint for e1 and en Lecture 15 20/ 21

slide-52
SLIDE 52

Inductive Proof of Theorem 2

Theorem 2 Let G be a connected graph with at least one edge. The graph G is Eulerian if and

  • nly if every node in G has even degree.
  • 1. If G is Eulerian, then every node has even degree

I Suppose G has an Eulerian circuit, and let x be any node in the graph I Write the Eulerian circuit as a walk v1e1v2e2 · · · vnenv1 I Since G is connected, x must be one of the vertices in the walk I Each time (if any) that x appears in the middle of the walk, it is the endpoint for

two different edges

I If x = v1, then it is the endpoint for e1 and en I So the degree of x is even Lecture 15 20/ 21

slide-53
SLIDE 53

Inductive Proof of Theorem 2

Theorem 2 Let G be a connected graph with at least one edge. The graph G is Eulerian if and

  • nly if every node in G has even degree.
  • 1. If G is Eulerian, then every node has even degree

I Suppose G has an Eulerian circuit, and let x be any node in the graph I Write the Eulerian circuit as a walk v1e1v2e2 · · · vnenv1 I Since G is connected, x must be one of the vertices in the walk I Each time (if any) that x appears in the middle of the walk, it is the endpoint for

two different edges

I If x = v1, then it is the endpoint for e1 and en I So the degree of x is even

  • 2. P(n): Every connected graph G with n edges and all even-degree nodes is Eulerian

Lecture 15 20/ 21

slide-54
SLIDE 54

Inductive Proof of Theorem 2

Theorem 2 Let G be a connected graph with at least one edge. The graph G is Eulerian if and

  • nly if every node in G has even degree.
  • 1. If G is Eulerian, then every node has even degree

I Suppose G has an Eulerian circuit, and let x be any node in the graph I Write the Eulerian circuit as a walk v1e1v2e2 · · · vnenv1 I Since G is connected, x must be one of the vertices in the walk I Each time (if any) that x appears in the middle of the walk, it is the endpoint for

two different edges

I If x = v1, then it is the endpoint for e1 and en I So the degree of x is even

  • 2. P(n): Every connected graph G with n edges and all even-degree nodes is Eulerian

I P(1) is trivially true (only such graph exists) Lecture 15 20/ 21 ~ a

loop

  • Q
slide-55
SLIDE 55

Inductive Proof of Theorem 2

Theorem 2 Let G be a connected graph with at least one edge. The graph G is Eulerian if and

  • nly if every node in G has even degree.
  • 1. If G is Eulerian, then every node has even degree

I Suppose G has an Eulerian circuit, and let x be any node in the graph I Write the Eulerian circuit as a walk v1e1v2e2 · · · vnenv1 I Since G is connected, x must be one of the vertices in the walk I Each time (if any) that x appears in the middle of the walk, it is the endpoint for

two different edges

I If x = v1, then it is the endpoint for e1 and en I So the degree of x is even

  • 2. P(n): Every connected graph G with n edges and all even-degree nodes is Eulerian

I P(1) is trivially true (only such graph exists) I Assume P(1), . . . P(m − 1) all hold, and consider a graph G with m edges Lecture 15 20/ 21

slide-56
SLIDE 56

Inductive Proof of Theorem 2

Theorem 2 Let G be a connected graph with at least one edge. The graph G is Eulerian if and

  • nly if every node in G has even degree.
  • 1. If G is Eulerian, then every node has even degree

I Suppose G has an Eulerian circuit, and let x be any node in the graph I Write the Eulerian circuit as a walk v1e1v2e2 · · · vnenv1 I Since G is connected, x must be one of the vertices in the walk I Each time (if any) that x appears in the middle of the walk, it is the endpoint for

two different edges

I If x = v1, then it is the endpoint for e1 and en I So the degree of x is even

  • 2. P(n): Every connected graph G with n edges and all even-degree nodes is Eulerian

I P(1) is trivially true (only such graph exists) I Assume P(1), . . . P(m − 1) all hold, and consider a graph G with m edges I By Proposition 40, there is a cycle C in G Lecture 15 20/ 21

slide-57
SLIDE 57

Inductive Proof of Theorem 2

Theorem 2 Let G be a connected graph with at least one edge. The graph G is Eulerian if and

  • nly if every node in G has even degree.
  • 1. If G is Eulerian, then every node has even degree

I Suppose G has an Eulerian circuit, and let x be any node in the graph I Write the Eulerian circuit as a walk v1e1v2e2 · · · vnenv1 I Since G is connected, x must be one of the vertices in the walk I Each time (if any) that x appears in the middle of the walk, it is the endpoint for

two different edges

I If x = v1, then it is the endpoint for e1 and en I So the degree of x is even

  • 2. P(n): Every connected graph G with n edges and all even-degree nodes is Eulerian

I P(1) is trivially true (only such graph exists) I Assume P(1), . . . P(m − 1) all hold, and consider a graph G with m edges I By Proposition 40, there is a cycle C in G I Form graph G 0 by removing the edges in C Lecture 15 20/ 21

slide-58
SLIDE 58

Inductive Proof of Theorem 2

Theorem 2 Let G be a connected graph with at least one edge. The graph G is Eulerian if and

  • nly if every node in G has even degree.
  • 1. If G is Eulerian, then every node has even degree

I Suppose G has an Eulerian circuit, and let x be any node in the graph I Write the Eulerian circuit as a walk v1e1v2e2 · · · vnenv1 I Since G is connected, x must be one of the vertices in the walk I Each time (if any) that x appears in the middle of the walk, it is the endpoint for

two different edges

I If x = v1, then it is the endpoint for e1 and en I So the degree of x is even

  • 2. P(n): Every connected graph G with n edges and all even-degree nodes is Eulerian

I P(1) is trivially true (only such graph exists) I Assume P(1), . . . P(m − 1) all hold, and consider a graph G with m edges I By Proposition 40, there is a cycle C in G I Form graph G 0 by removing the edges in C I Each connected component H1, . . . , Hk has nodes of even degree and—by

inductive assumption—has an Eulerian circuit C1, . . . , Ck

Lecture 15 20/ 21

slide-59
SLIDE 59

Inductive Proof of Theorem 2

Theorem 2 Let G be a connected graph with at least one edge. The graph G is Eulerian if and

  • nly if every node in G has even degree.
  • 1. If G is Eulerian, then every node has even degree

I Suppose G has an Eulerian circuit, and let x be any node in the graph I Write the Eulerian circuit as a walk v1e1v2e2 · · · vnenv1 I Since G is connected, x must be one of the vertices in the walk I Each time (if any) that x appears in the middle of the walk, it is the endpoint for

two different edges

I If x = v1, then it is the endpoint for e1 and en I So the degree of x is even

  • 2. P(n): Every connected graph G with n edges and all even-degree nodes is Eulerian

I P(1) is trivially true (only such graph exists) I Assume P(1), . . . P(m − 1) all hold, and consider a graph G with m edges I By Proposition 40, there is a cycle C in G I Form graph G 0 by removing the edges in C I Each connected component H1, . . . , Hk has nodes of even degree and—by

inductive assumption—has an Eulerian circuit C1, . . . , Ck

I Each of these must meet C, say, at v1, v2, . . . , vk Lecture 15 20/ 21

slide-60
SLIDE 60

Inductive Proof of Theorem 2

Theorem 2 Let G be a connected graph with at least one edge. The graph G is Eulerian if and

  • nly if every node in G has even degree.
  • 1. If G is Eulerian, then every node has even degree

I Suppose G has an Eulerian circuit, and let x be any node in the graph I Write the Eulerian circuit as a walk v1e1v2e2 · · · vnenv1 I Since G is connected, x must be one of the vertices in the walk I Each time (if any) that x appears in the middle of the walk, it is the endpoint for

two different edges

I If x = v1, then it is the endpoint for e1 and en I So the degree of x is even

  • 2. P(n): Every connected graph G with n edges and all even-degree nodes is Eulerian

I P(1) is trivially true (only such graph exists) I Assume P(1), . . . P(m − 1) all hold, and consider a graph G with m edges I By Proposition 40, there is a cycle C in G I Form graph G 0 by removing the edges in C I Each connected component H1, . . . , Hk has nodes of even degree and—by

inductive assumption—has an Eulerian circuit C1, . . . , Ck

I Each of these must meet C, say, at v1, v2, . . . , vk I “Insert” each Ci into C to obtain desired circuit

(Arrange C to start and end at vi and write Ci in place of vi in C)

Lecture 15 20/ 21

slide-61
SLIDE 61

Reminder of Earlier Example

Lecture 15 21/ 21

7 3 4 5 6 8 9 10 14 12 13 11 7 1 2 3 4 5 6 8 9 10 14 12 13 11 7 1 2 3 8 14 11