Çizge Algoritmaları.

Slides:



Advertisements
Similar presentations
Graph Theory: Euler Circuits Christina Mende Math 480 April 15, 2013.
Advertisements

BY: MIKE BASHAM, Math in Scheduling. The Bridges of Konigsberg.
Euler Circuits and Paths
Koenigsberg bridge problem It is the Pregel River divided Koenigsberg into four distinct sections. Seven bridges connected the four portions of Koenigsberg.
E ULERIZING G RAPHS Notes 25 - Section 5.7. E SSENTIAL L EARNINGS Students will understand and be able to use Eulerization to find optimal exhaustive.
Section 2.1 Euler Cycles Vocabulary CYCLE – a sequence of consecutively linked edges (x 1,x2),(x2,x3),…,(x n-1,x n ) whose starting vertex is the ending.
An Euler Circuit is a cycle of an undirected graph, that traverses every edge of the graph exactly once, and ends at the same node from which it began.
Math Foundations Week 12 Graphs (2). Agenda Paths Connectivity Euler paths Hamilton paths 2.
Homework collection Thursday 3/29 Read Pages 160 – 174 Page 185: 1, 3, 6, 7, 8, 9, 12 a-f, 15 – 20.
4/17/2017 Section 8.5 Euler & Hamilton Paths ch8.5.
Euler Circuit Chapter 5. Fleury’s Algorithm Euler’s theorems are very useful to find if a graph has an Euler circuit or an Euler path when the graph is.
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley.
Discrete Math Round, Round, Get Around… I Get Around Mathematics of Getting Around.
GRAPH Learning Outcomes Students should be able to:
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley.
Slide 14-1 Copyright © 2005 Pearson Education, Inc. SEVENTH EDITION and EXPANDED SEVENTH EDITION.
1 Excursions in Modern Mathematics Sixth Edition Peter Tannenbaum.
5.1  Routing Problems: planning and design of delivery routes.  Euler Circuit Problems: Type of routing problem also known as transversability problem.
Euler Paths & Euler Circuits
5.7 Eulerizing Graphs. Euler circuit and Euler path do not always exist. There are many graphs (in real life) that have more than 2 odd vertices. Instead.
Spring 2015 Mathematics in Management Science Chinese Postman Problem What is CPP? CPP & ECs & EPs Fleury’s Algorithm Eulerization.
5.4 Graph Models (part I – simple graphs). Graph is the tool for describing real-life situation. The process of using mathematical concept to solve real-life.
Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
Aim: What is an Euler Path and Circuit?
Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. 5 The Mathematics of Getting Around 5.1Euler Circuit Problems 5.2What.
Vertex-Edge Graphs Euler Paths Euler Circuits. The Seven Bridges of Konigsberg.
AND.
Euler Paths and Circuits. The original problem A resident of Konigsberg wrote to Leonard Euler saying that a popular pastime for couples was to try.
© 2010 Pearson Prentice Hall. All rights reserved. CHAPTER 15 Graph Theory.
Copyright 2013, 2010, 2007, Pearson, Education, Inc. Section 14.2 Euler Paths, and Euler Circuits.
Chapter 6: Graphs 6.1 Euler Circuits
Aim: Graph Theory – Paths & Circuits Course: Math Literacy Do Now: Aim: What are Circuits and Paths? Can you draw this figure without retracing any of.
Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. 5 The Mathematics of Getting Around 5.1Euler Circuit Problems 5.2What.
1) Find and label the degree of each vertex in the graph.
Graph Theory Euler Paths and Euler Circuits. Euler Paths & Circuits Euler Paths and Euler Circuits (Euler is pronounced the same as Oiler) An Euler path.
Fleury's Algorithm Euler Circuit Algorithm
Grade 11 AP Mathematics Graph Theory Definition: A graph, G, is a set of vertices v(G) = {v 1, v 2, v 3, …, v n } and edges e(G) = {v i v j where 1 ≤ i,
1 GRAPH Learning Outcomes Students should be able to: Explain basic terminology of a graph Identify Euler and Hamiltonian cycle Represent graphs using.
MAT 110 Workshop Created by Michael Brown, Haden McDonald & Myra Bentley for use by the Center for Academic Support.
An Introduction to Graph Theory
Excursions in Modern Mathematics Sixth Edition
Excursions in Modern Mathematics Sixth Edition
Excursions in Modern Mathematics Sixth Edition
Euler and Hamilton Cycles; Planar Graphs; Coloring.
CSNB 143 Discrete Mathematical Structures
Graphs Hubert Chan (Chapter 9) [O1 Abstract Concepts]
Euler Paths and Circuits
Eulerian tours Miles Jones MTThF 8:30-9:50am CSE 4140 August 15, 2016.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett
Can you draw this picture without lifting up your pen/pencil?
Euler Paths and Circuits
Euler Circuits and Paths
Euler Paths & Euler Circuits
Introduction to Graph Theory Euler and Hamilton Paths and Circuits
Graph Theory.
Genome Assembly.
5 The Mathematics of Getting Around
Excursions in Modern Mathematics Sixth Edition
5 The Mathematics of Getting Around
Konigsberg- in days past.
Euler Circuits and Paths
5 The Mathematics of Getting Around
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley.
Euler and Hamilton Paths
Euler Paths and Euler Circuits
Applied Combinatorics, 4th Ed. Alan Tucker
Warm Up – 3/19 - Wednesday Give the vertex set. Give the edge set.
Hamilton Paths and Circuits
A Survey of Mathematics with Applications
5 The Mathematics of Getting Around
Presentation transcript:

Çizge Algoritmaları

Pencil Drawing Problem -Euler Paths Which of the following pictures can be drawn on paper without ever lifting the pencil and without retracing over any segment?

Definitions An Euler path is a path that passes through each edge of a graph exactly one time. An Euler circuit is a circuit that passes through each edge of a graph exactly one time. The difference between an Euler path and an Euler circuit is that an Euler circuit must start and end at the same vertex.

Example: Recognizing Euler Circuits Consider the graph below. Is an Euler circuit? b) Does the graph have an Euler circuit? E F D A C B

Example: Recognizing Euler Circuits Solution a) No, it does not use edge BD. b) Yes, the circuit is an Euler circuit. E F D A C B

Examples Euler path Euler circuit

Euler Theorem Euler’s Theorem The following statements are true for connected graphs: If a graph has exactly two odd vertices, then it has at least one Euler path, but no Euler circuit. Each Euler path must start at one of the odd vertices and end at the other. If a graph has no odd vertices (all even vertices), it has at least one Euler circuit. An Euler circuit can start and end at any vertex. If a graph has more than two odd vertices, then it has no Euler paths and no Euler circuits.

Euler’s Theorem Suppose we have a connected graph. 1. If the graph has an Euler circuit, then each vertex of the graph has even degree. 2. If each vertex of the graph has even degree, then the graph has an Euler circuit.

Finding Euler Paths To find Euler paths, we’ll first give an algorithm for finding Euler cycles and then modify it to give Euler paths. THM: An undirected graph G has an Euler circuit iff it is connected and every vertex has even degree. NOTE: for directed graphs the condition is that G be weakly connected and that every vertex has same in-degree as out-degree. L25

Finding Euler Circuits Q: Why does the following graph have no Euler circuit?

Finding Euler Circuits A: It contains a vertex of odd degree. L25

Generalizing to Euler Paths Q: Does the following have an Euler circuit?

Generalizing to Euler Paths A: No, vertices of odd degree: Q: But why does it have an Euler path? L25

Generalizing to Euler Paths A: YES! Because exactly 2 vertices of odd degree. So can add a phantom edge between odd degree vertices: L25

Generalizing to Euler Paths All degrees now even so find Euler cycle:

Generalizing to Euler Paths Now remove phantom edge obtaining: 1 2 3 7 4 6 5 L25

Example: Using Euler’s Theorem Use Euler’s theorem to determine whether an Euler path or an Euler circuit exists in the figures shown from the previous example. A B C D A B C D E

Example: Using Euler’s Theorem continued The graph has no odd vertices (all vertices are even). According to item 1, at least one Euler circuit exists. An Euler circuit can be determined by starting at any vertex. The Euler circuit will end at the vertex from which is started. Remember that each Euler circuit is also an Euler path. A B C D

Example: Using Euler’s Theorem continued There are 3 even vertices (A, B, C) and two odd vertices (D, E). Based on item 2, we conclude that since there are exactly two odd vertices, at least one Euler path exists but no Euler circuits exists. Each Euler path must begin at one of the odd vertices and end at the other odd vertex. A B C D E

Model Problem Explain why the graph has at least one Euler path. degree 2 D C B E A number of edges at each vertex: degree 4 degree 4 A: 2 D: 3 B: 4 E: 3 C: 4 degree 3 degree 3 Two odd vertices If a graph has exactly two odd vertices, then it has at least one Euler path, but no Euler circuit. Each Euler path must start at one of the odd vertices and end at the other.

Model Problem Find a Euler path. D C B E A 6 5 2 3 7 4 1 8 D, C, B, E,

Model Problem Explain why the graph has a least one Euler circuit. degree 2 degree 4 degree 4 degree 2 degree 2 degree 4 degree 4 degree 2 no odd vertices 2. If a graph has no odd vertices (all even vertices), it has at least one Euler circuit. An Euler circuit can start and end at any vertex.

Model Problem Find an Euler circuit. 11 10 12 9 3 13 4 8 2 14 1 5 7 6 H, G, E, C, G, I, J, H, D, C, A, B, D, F, H Euler Circuit – a circuit that travels through every edge of a graph once and only once, and must begin and end at the same vertex.

Model Problem A, B, C, and D represent rooms. The outside of the house is labeled E. The openings represent doors. a) Is it possible to find a path that uses each door exactly once? degree 6 degree 3 look for a Euler path or circuit exactly 2 odd vertices If a graph has exactly two odd vertices, then it has at least one Euler path, but no Euler circuit. Each Euler path must start at one of the odd vertices and end at the other.

Model Problem A, B, C, and D represent rooms. The outside of the house is labeled E. The openings represent doors. b) If possible, find such a path. 9 10 7 2 1 3 8 6 4 5 start at one of the odd vertices B, E, A, B, D, C, A, E, C, E, D

Fluery’s Algorithm If Euler’s Theorem indicates the existence of an Euler path or Euler circuit, one can be found using the following procedure. If the graph has exactly two odd vertices, chose one of the two odd vertices as the starting point. If the graph has no odd vertices, choose any vertex as the starting point. Number edges as you trace through the graph according to the following rules: After you traveled over an edge, change it to a dashed line. When faced with a choice of edges to trace, choose an edge that is not a bridge (an edge, which, if removed from a connected graph would leave behind a disconnected graph). Travel over an edge that is a bridge only if there is no alternative.

Fleury’s Algorithm To determine an Euler path or an Euler circuit: 1. Use Euler’s theorem to determine whether an Euler path or an Euler circuit exists. If one exists, proceed with steps 2-5. 2. If the graph has no odd vertices (therefore has an Euler circuit, which is also an Euler path), choose any vertex as the starting point. If the graph has exactly two odd vertices (therefore has only an Euler path), choose one of the two odd vertices as the starting point.

Fleury’s Algorithm continued 3. Begin to trace the edges as you move through the graph. Number the edges as you trace them. Since you can’t trace any edges twice in Euler paths and Euler circuits, once an edge is traced consider it “invisible.” 4. When faced with a choice of edges to trace, if possible, choose an edge that is not a bridge (i.e., don’t create a disconnected graph with your choice of edges). 5. Continue until each edge of the entire graph has been traced once.

Euler Circuits Fleury’s Algorithm for Finding an Euler Circuit (Path) Preliminaries. Make sure that the graph is connected and either (1) has no odd vertices (circuit), or (2) has two odd vertices (path).

Euler Circuits Fleury’s Algorithm for Finding an Euler Circuit (Path) Start. Choose a starting vertex. [ In case (1) this can be any vertex; in case (2) it must be one of the two odd vertices.]

Euler Circuits Fleury’s Algorithm for Finding an Euler Circuit (Path) Intermediate steps. At each step, if you have a choice, don’t choose a bridge of the yet-to-be-traveled part of the graph. However, if you have only one choice, take it.

Euler Circuits Fleury’s Algorithm for Finding an Euler Circuit (Path) Intermediate steps. At each step, if you have a choice, don’t choose a bridge of the yet-to-be-traveled part of the graph. However, if you have only one choice, take it.

Euler Circuits Fleury’s Algorithm for Finding an Euler Circuit (Path) Intermediate steps. At each step, if you have a choice, don’t choose a bridge of the yet-to-be-traveled part of the graph. However, if you have only one choice, take it.

Euler Circuits Fleury’s Algorithm for Finding an Euler Circuit (Path) Intermediate steps. At each step, if you have a choice, don’t choose a bridge of the yet-to-be-traveled part of the graph. However, if you have only one choice, take it.

Euler Circuits Fleury’s Algorithm for Finding an Euler Circuit (Path) Intermediate steps. At each step, if you have a choice, don’t choose a bridge of the yet-to-be-traveled part of the graph. However, if you have only one choice, take it.

Euler Circuits Fleury’s Algorithm for Finding an Euler Circuit (Path) End. When you can’t travel any more, the circuit (path) is complete. [In case (1) you will be back at the starting vertex; in case (2) you will end at the other odd vertex.]

Example Use Fluery’s algorithm to determine an Euler circuit. There is at least one Euler circuit since there are no odd vertices. Start at any vertex to determine an Euler circuit. A B C D E F G

Example continued Start at C. Choose either CB or CD. Continue to trace from vertex to vertex around the outside of the graph. A B C D E F G 1 2 3 4 5 6 7 8 9 10 start here

Example continued Start at C. Choose either CB or CD. Continue to trace from vertex to vertex around the outside of the graph. A B C D E F G 1 2 3 4 5 6 7 8 9 10 start here

Model Problem The graph has at least one Euler circuit. Find it using Fleury’s Algorithm. F 7 E 6 4 3 8 2 D C 5 1 9 B A no odd vertices, begin at any vertex.

Fleury's Algorithm: O(E)? Pick any vertex to start. From that vertex pick an edge to traverse, considering following rule: never cross a bridge of the reduced graph unless there is no other choice. Darken that edge, as a reminder that you can't traverse it again. Travel that edge, coming to the next vertex. Repeat 2-4 until all edges have been traversed, and you are back at the starting vertex. By reduced graph we mean the original graph minus the darkened (already used) edges. A bridge of a graph G is an edge whose deletion increases the number of components of G.

Fleury's Algorithm in Action Pick any vertex (e.g. F) Take F to C  (arbitrary) Take C to D  (arbitrary) Take D to A  (arbitrary) A bridge is not a local property (i.e. if edge EF existed then AB would not be a bridge). How can we recognize a bridge efficiently? In the original graph, AB was not a bridge. Can we preprocess the graph in O(E) time identifying bridges and building a structure that can be updated in constant time with each reduction? Take A to C. Can't go to B: that edge is a bridge of the reduced graph, and there are two other choices.

Euler Paths and Circuits Definition DEF: An Euler path in a graph G is a simple path containing every edge in G. An Euler circuit (or Euler cycle) is a cycle which is an Euler path. NOTE: The definition applies both to undirected as well as directed graphs of all types. L25

Euler Circuits Eulerizing Graphs Our first step is to identify the odd vertices. This graph has eight odd vertices (B,C,E,F,H,I,K,and L), shown in red.

Euler Circuits Eulerizing Graphs When we add a duplicate copy of edges BC,EF,HI, and KL, we get this graph. This is the eulerized version of the original graph.

Euler Circuits Eulerizing Graphs This graph shows the many possible Euler circuits,with the edges numbered in the order they are traveled..

Euler Circuits Eulerizing Graphs With the four duplicate edges (BC,EF,HI,and KL) indicating the deadhead blocks where a second pass is required. The total length of this route is 28 blocks (24 blocks in the grid plus 4 deadhead blocks).

Euler Circuits Eulerizing Graphs In some situations we need to find an exhaustive route, but there is no requirement that it be closed—the route may start and end at different points.

Euler Circuits Eulerizing Graphs In these cases, we want to leave two odd vertices on the graph unchanged, and change the other odd vertices into even vertices.

Euler Circuits Eulerizing Graphs This process id called a semi-eulerization of the graph. In this case the route will start at one of the two odd vertices and end at the other one.