Presentation is loading. Please wait.

Presentation is loading. Please wait.

Euler Circuits and Paths

Similar presentations


Presentation on theme: "Euler Circuits and Paths"— Presentation transcript:

1 Euler Circuits and Paths

2 Exploration Is it possible to draw this figure without lifting your pencil from the paper and without tracing any of the lines more than once?

3 Leonard Euler This problem is an 18th century problem that intrigued Swiss mathematician Leonard Euler ( ). This problem was posed by the residents of Königsberg, a city in what was then Prussia but is now Kaliningrad.

4 Königsberg Bridges In the 1700s, seven bridges connected two islands on the Pregel River to the rest of the city. The people wondered whether it would be possible to walk through the city by crossing each bridge exactly once and return to the original starting point.

5 Euler’s Solution Using a graph like the picture where the vertices represent the landmasses of the city and the edges represent the bridges, Euler was able to find that the desired walk throughout the city was not possible. In doing so, he also discovered a solution to problems of this general type.

6 Euler’s Solution (cont’d)
Try to transverse the graph without lifting your pencil of tracing the lines more than once. When can you draw figures without retracing any of the edges and still end up at your starting point? When can you draw the figure without retracing and end up at a point other than the one from which you began? When can you not draw the figure without retracing?

7 Euler’s Solution (cont’d)
Euler found that the key to the solution was related to the degrees of the vertices. Recall that the degree of a vertex is the number of the edges that have the vertex as an endpoint. Find the degree of each vertex of the graphs on the next slide. Do you see what Euler noticed?

8 Degree of the Vertex

9 Euler’s Solution Euler found that in order to be able to transverse each edge of a connected graph exactly once and to end at the starting vertex, the degree of each vertex of the graph must be even. (As only in the second graph)

10 Euler Circuits and Paths
In his honor, a path that uses each edge of a graph exactly once and ends at the starting vertex is called an Euler circuit. Euler also noticed that if a connected graph had exactly two odd vertices, it was possible to use each edge of the graph exactly once but to end at a vertex different from the starting vertex. Such a path is called an Euler path.

11 Euler Circuits and Paths (cont’d)
Notice that the first graph is an example of an Euler path. The last graph, however, has four odd vertices and so it cannot be traced without lifting the pencil. It is neither an Euler path nor an Euler circuit.

12 Finding Euler Circuits
Finding an Euler circuit in a small graph can usually be found relatively easily by trial and error. However, as the number of vertices and edges increases, a systematic way of finding the circuit becomes necessary. The following algorithm gives one way of finding and Euler circuit for a connected graph with all vertices of even degree.

13 Euler Circuit Algorithm
Pick any vertex and label it S. Construct a circuit, C, that begins and ends at S. If C is a circuit that includes all edges of the graph, go to Step 8. Choose a vertex, V, that is in C and has an edge that is not in C. Construct a circuit C’ that starts and ends at V using edges not in C.

14 Euler Circuit Algorithm (cont’d)
Combine C and C’ to form a new circuit. Call this New circuit C. Go to Step 3. Stop. C is an Euler circuit for the graph.

15 Example Use the Euler circuit algorithm to find an Euler circuit for the graph below. c d a b e i f h g

16 Using the Algorithm Apply Step 1 of the algorithm. Choose vertex b, and label it S. Let C be the circuit S, c, d, e, a, S. C does not contain all edges of the graph, so go to Step 4 of the algorithm. Choose vertex d. Let C’ be the circuit d, g, f, e, g, h, e, I, h, b, d.

17 Algorithm (cont’d) Combine C and C’ by replacing vertex d in the circuit C with the circuit C’. Let C now be the circuit S, c, d, g, f, e, g, h, e, I, h, s, d, e, a, S. Go to Step 3 of the algorithm. C now contains all edges of the graph, so go to Step 8 of the algorithm and stop. C is an Euler circuit for the graph.

18 Directionality in Graphs
Sometimes a graph application requires that edges have directionality. An example of this can be seen in a city that has one-way streets. A graph that has directed edges, edges that can be traversed in only one direction, is known as a digraph. The number of edges going into a vertex is known as the indegree of the vertex and the number of edges coming out of a vertex is known as the outdegree.

19 Ordered Edges= {AB, BA, BC, CA, DB, AD}
An Example of a Digraph The digraph on the next slide can be described by the following set of vertices and set of ordered edges: Vertices={A, B, C, D} Ordered Edges= {AB, BA, BC, CA, DB, AD} If you follow the indicated direction of each edge, is it possible to draw this digraph and end up at the vertex where you started? That is, does the digraph have a directed circuit?

20 Digraph Check the indegree and outdegree of each vertex.
A connected diagraph has a Euler circuit if the indegree and outdegree of each vertex are equal. B A C D

21 Practice Problems State whether the graph has an Euler circuit, an Euler path, or neither. Explain why. a. c. d. ` b.

22 Practice Problems (cont’d)
2. Sally began using the Euler circuit algorithm to find the Euler circuit for the graph below. She started at vertex s and labeled it S. The first circuit she found was S, e, f, a, b, c, S. Using Sally’s start, continue the algorithm, and find the Euler circuit for the graph. a b e g c d S f

23 Practice Problems (cont’d)
3. Use the Euler circuit algorithm to find an Euler circuit for the following graph: c d b e a h g f

24 Practice Problems (cont’d)
The Euler circuit algorithm is to be used for “connected graphs with all vertices of even degree.” Why is it necessary to state that the graph must be connected? Give an example of a graph with all vertices of even degree that does not have an Euler circuit. Will a complete graph with two vertices have an Euler circuit? Three vertices? Four vertices? Five vertices, or n vertices?

25 Practice Problems (cont’d)
6. The present-day Königsberg has two more bridges than it did in Euler’s time. One more bridge was added to connect the two banks of the river, A to B, in the figure below. Another one was added to link the land to one of the islands, B to D. Is it now possible to make the famous walk and return to the starting point? A C D B

26 Practice Problems (cont’d)
The streets of a city can be described by a graph in which the vertices represent the street corners and the edges represent the streets. Suppose you are the city street inspector and it is desirable to minimize time and cost by not inspecting the same street more than once.

27 Practice Problems (cont’d)
Is it possible to begin at the garage (g) and inspect each street only once? Will you be back at the garage at the end of the inspection? Find a route that inspects all streets, repeats the number of edges and returns to the garage.

28

29 Practice Problems (cont’d)
Diagram: a c b d e j f h i G

30 Practice Problems (cont’d)
Construct the following digraphs: a. V={A, B, C, D, E} E={AB, CB, CE, DE, DA} b. V={W, X, Y, Z} E={WX, XZ, ZY, YW, XY, YX}

31 Practice Problems (cont’d)
Determine whether the digraph has a directed Euler circuit. a b. c.

32 Practice Problems (cont’d)
Does the following digraph have a directed Euler circuit? Why or why not? Does it have a directed Euler path? If it does, which vertex must be the starting vertex? When does a digraph have an Euler path? f b c g d a e

33 Practice Problems (cont’d)
A digraph can be represented by an adjacency matrix. If there is a directed edge from vertex a to vertex b, then a 1 is placed in row a, column b, of the matrix; otherwise a zero is entered. Matrix M is the adjacency matrix for the graph below: M= b a c

34 Practice Problems (cont’d)
Find the adjacency matrix for each of the following digraphs: B b A C c a T S D d e X V W

35 Practice Problems (cont’d)
Construct a digraph for the following adjacency matrix: a. Is there symmetry along the main diagonal of the adjacency matrix?

36 Practice Problems (cont’d)
Find the sum of the numbers in the second row. What does that total indicate? Find the sum of the numbers in the second column. What does that total indicate?


Download ppt "Euler Circuits and Paths"

Similar presentations


Ads by Google