Eulerian Paths and Cycles. What is a Eulerian Path Given an graph. Find a path which uses every edge exactly once. This path is called an Eulerian Path.

Slides:



Advertisements
Similar presentations
CS 336 March 19, 2012 Tandy Warnow.
Advertisements

Great Theoretical Ideas in Computer Science
Coloring Warm-Up. A graph is 2-colorable iff it has no odd length cycles 1: If G has an odd-length cycle then G is not 2- colorable Proof: Let v 0, …,
Chapter 8 Topics in Graph Theory
Lecture 5 Graph Theory. Graphs Graphs are the most useful model with computer science such as logical design, formal languages, communication network,
22C:19 Discrete Math Graphs Fall 2010 Sukumar Ghosh.
Introduction to Graph Theory Instructor: Dr. Chaudhary Department of Computer Science Millersville University Reading Assignment Chapter 1.
Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.
Graph-02.
Great Theoretical Ideas in Computer Science for Some.
Section 14.1 Intro to Graph Theory. Beginnings of Graph Theory Euler’s Konigsberg Bridge Problem (18 th c.)  Can one walk through town and cross all.
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley. All rights reserved.
Applied Combinatorics, 4th Ed. Alan Tucker
Great Theoretical Ideas in Computer Science.
Last time: terminology reminder w Simple graph Vertex = node Edge Degree Weight Neighbours Complete Dual Bipartite Planar Cycle Tree Path Circuit Components.
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
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.
What is the first line of the proof? a). Assume G has an Eulerian circuit. b). Assume every vertex has even degree. c). Let v be any vertex in G. d). Let.
Introduction to Graphs Lecture 18: Nov 16. Seven Bridges of Königsberg Is it possible to walk with a route that crosses each bridge exactly once?
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.
Representing Graphs Wade Trappe. Lecture Overview Introduction Some Terminology –Paths Adjacency Matrix.
Linked Lists1 Part-B3 Linked Lists. Linked Lists2 Singly Linked List (§ 4.4.1) A singly linked list is a concrete data structure consisting of a sequence.
Graph Colouring Lecture 20: Nov 25.
Is the following graph Hamiltonian- connected from vertex v? a). Yes b). No c). I have absolutely no idea v.
What is the first line of the backwards direction of this proof? 1.Assume G is a block. 2.Assume every pair of vertices lie on a common cycle. 3.Assume.
Minimum Spanning Trees. Subgraph A graph G is a subgraph of graph H if –The vertices of G are a subset of the vertices of H, and –The edges of G are a.
Eulerian Graphs CSE 331 Section 2 James Daly. Reminders Project 3 is out Covers graphs Due Friday.
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.
Eulerian Tours By Shaylan Lalloo. What is an Eulerian Tour? A path that uses every edge exactly once is called an eularian tour. Furthermore, a path that.
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
Eulerian Tour What is a Eulerian tour and how to find one.
7.1 Introduction to Graph Theory
5.1  Routing Problems: planning and design of delivery routes.  Euler Circuit Problems: Type of routing problem also known as transversability problem.
Graph Algorithms Mathematical Structures for Computer Science Chapter 6 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesGraph Algorithms.
Euler and Hamilton Paths. Euler Paths and Circuits The Seven bridges of Königsberg a b c d A B C D.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
Introduction to Graph Theory
1.5 Graph Theory. Graph Theory The Branch of mathematics in which graphs and networks are used to solve problems.
Graph Colouring Lecture 20: Nov 25. This Lecture Graph coloring is another important problem in graph theory. It also has many applications, including.
Graph Theory. A branch of math in which graphs are used to solve a problem. It is unlike a Cartesian graph that we used throughout our younger years of.
Associated Matrices of Vertex Edge Graphs Euler Paths and Circuits Block Days April 30, May 1 and May
Graph theory and networks. Basic definitions  A graph consists of points called vertices (or nodes) and lines called edges (or arcs). Each edge joins.
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.
MAT 2720 Discrete Mathematics Section 8.2 Paths and Cycles
Lecture 52 Section 11.2 Wed, Apr 26, 2006
Lecture 11: 9.4 Connectivity Paths in Undirected & Directed Graphs Graph Isomorphisms Counting Paths between Vertices 9.5 Euler and Hamilton Paths Euler.
Topological Sort: Definition
Chapter 6: Graphs 6.1 Euler Circuits
Walks, Paths and Circuits. A graph is a connected graph if it is possible to travel from one vertex to any other vertex by moving along successive edges.
Introduction to Graph Theory
1) Find and label the degree of each vertex in the graph.
Graphs Definition: a graph is an abstract representation of a set of objects where some pairs of the objects are connected by links. The interconnected.
Trees.
CS Lecture 22 Graph Theory. Can I draw the above figure in one continuous trace with no line being drawn twice?
Euler Paths and Circuits
Eulerian tours Miles Jones MTThF 8:30-9:50am CSE 4140 August 15, 2016.
Great Theoretical Ideas in Computer Science
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett
Discrete Mathematics for Computer Science
Can you draw this picture without lifting up your pen/pencil?
This unit is all about Puzzles Games Strategy.
Introduction to Graph Theory Euler and Hamilton Paths and Circuits
Genome Assembly.
A path that uses every vertex of the graph exactly once.
Euler and Hamilton Paths
Euler circuit Theorem 1 If a graph G has an Eulerian path, then it must have exactly two odd vertices. Theorem 2 If a graph G has an Eulerian circuit,
Applied Combinatorics, 4th Ed. Alan Tucker
Warm Up – 3/19 - Wednesday Give the vertex set. Give the edge set.
Warm Up – 3/14 - Friday 100 seats are to be apportioned.
Graph Theory Proof In Class Exercise.
Presentation transcript:

Eulerian Paths and Cycles

What is a Eulerian Path Given an graph. Find a path which uses every edge exactly once. This path is called an Eulerian Path. If the path begins and ends at the same vertex, it is called a Eulerian Cycle.

Where did all start: Koningsberg

Koningsberg Find a route which crosses each bridge exactly once?

Koningsberg Graph This graph represents the Koningsburg bridges

When do Eulerian Paths and Cycles exist? Euler’s solution An Eulerian cycle exists if and only if it is connected and every node has ‘even degree’. An Eulerian path exists if and only if it is connected and every node except two has even degree. In the Eulerian path the 2 nodes with odd degree have to be the start and end vertices

Proof: a Eulerian graph must have all vertices of even degree Let C be an Eulerian cycle of graph G, which starts and ends at vertex u. Each time a vertex is included in the cycle C, two edges connected to that vertex are used up. Every edge in G is included in the cycle. So every vertex other than u must have even degree. The tour starts and ends at u, so it must also have even degree.

Proof: a graph with all vertices of even degree must be Eulerian Assume the opposite: G is a non-eulerian graph with all vertices of even degree. G must contain a cycle. Let C be the largest possible cycle in the graph. Because of our assumption, C must have missed out some of the graph G, call this D. C is Eulerian, so has no vertices of odd degree. D therefore also has no vertices of odd degree. D must have some cycle E which shares a common vertex with C Combination of C and E therefore makes a cycle larger than C, which violates our assumption in (2). Contradiction.

Examples Eulerian Cycle: Eulerian Path:

And Koningsburg? No Eulerian Path or cycle!

Finding Eulerian Cycles Start off with a node Find a cycle containing that node Find a node along that path which has an edge that has not been used Find a cycle starting at this node witch uses the unused edge Splice this new cycle into the existing cycle Continue in this way until no nodes exist with unused edges Since the graph is connected this implies we have found a Eulerian Cycle

Formal Algorithm Pick a starting node and recurse on that node. At each step: If the node has no neighbors, then append the node to the circuit and return If the node has a neighbor, then make a list of the neighbors and process them until the node has no more neighbors To process a neighbour, delete the edge between the current node and its neighbor, recurse on the neighbor After processing all neighbours append current node to the circuit.

Pseudo-Code find_circuit (node i) if node i has no neighbors circuit [circuitpos] = node i circuitpos++ else while (node i has neighbors) pick a neighbor j of node i delete_edges (node j, node i) find_circuit (node j) circuit [circuitpos] = node i circuitpos++

Execution Example Stack: Location: Circuit:

Execution Example Stack: Location: Circuit:

Execution Example Stack: Location: 1 Circuit:

Execution Example Stack: Location: 1 Circuit:

Execution Example Stack: 1 Location: 4 Circuit:

Execution Example Stack: 1 4 Location: 2 Circuit:

Execution Example Stack: Location: 5 Circuit:

Execution Example Stack: Location: 1 Circuit:

Execution Example Stack: Location: 5 Circuit:

Execution Example Stack: Location: 6 Circuit:

Execution Example Stack: Location: 2 Circuit:

Execution Example Stack: Location: 7 Circuit:

Execution Example Stack: Location: 3 Circuit:

Execution Example Stack: Location: 4 Circuit:

Execution Example Stack: Location: 6 Circuit:

Execution Example Stack: Location: 7 Circuit:

Execution Example Stack: Location: 5 Circuit:

Execution Example Stack: Location: 7 Circuit:

Execution Example Stack: Location: 6 Circuit:

Execution Example Stack: Location: 4 Circuit:

Execution Example Stack: Location: 3 Circuit:

Execution Example Stack: Location: 7 Circuit:

Execution Example Stack: Location: 2 Circuit:

Execution Example Stack: Location: 6 Circuit:

Execution Example Stack: Location: 5 Circuit:

Execution Example Stack: 1 4 Location: 2 Circuit:

Execution Example Stack: 1 Location: 4 Circuit:

Execution Example Stack: Location: 1 Circuit:

Execution Example Stack: Location: Circuit:

Analysis To find an Eulerian path, find one of the nodes which has odd degree (or any node if there are no nodes with odd degree) and call find_circuit with it. This algorithm runs in O(m + n) time, where m is the number of edges and n is the number of nodes, if you store the graph in adjacency list form.