Euler and Hamilton paths. Jorge A. Cobb The University of Texas at Dallas

Similar documents
Introduction to Graphs

Varying Applications (examples)

6.2. Paths and Cycles

Graph Theory CS/Math231 Discrete Mathematics Spring2015

2. CONNECTIVITY Connectivity

Crossing bridges. Crossing bridges Great Ideas in Theoretical Computer Science. Lecture 12: Graphs I: The Basics. Königsberg (Prussia)

Notes for Recitation 9

Chapter 11: Graphs and Trees. March 23, 2008

Paths, Circuits, and Connected Graphs

Chapter 3: Paths and Cycles

EECS 203 Lecture 20. More Graphs

Network Topology and Graph

CHAPTER 10 GRAPHS AND TREES. Alessandro Artale UniBZ - artale/z

Elements of Graph Theory

1. The Highway Inspector s Problem

#30: Graph theory May 25, 2009

Graph Theory. Part of Texas Counties.

Approximation Algorithms

Graph Algorithms. Tours in Graphs. Graph Algorithms

The Traveling Salesman Problem Outline/learning Objectives The Traveling Salesman Problem

Graph Traversals. CSC 1300 Discrete Structures Villanova University. Villanova CSC Dr Papalaskari 1

SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics. An Introduction to Graph Theory

Introduction III. Graphs. Motivations I. Introduction IV

How can we lay cable at minimum cost to make every telephone reachable from every other? What is the fastest route between two given cities?

Scheduling, Map Coloring, and Graph Coloring

8.2 Paths and Cycles

Sarah Will Math 490 December 2, 2009

Graphs: Definitions Trails, Paths, and Circuits Matrix Representations Isomorphisms. 11. Graphs and Trees 1. Aaron Tan. 30 October 3 November 2017

Understand graph terminology Implement graphs using

3 Euler Tours, Hamilton Cycles, and Their Applications

Chapter 14 Section 3 - Slide 1

11.2 Eulerian Trails

Fundamental Properties of Graphs

Topic 10 Part 2 [474 marks]

INTRODUCTION TO GRAPH THEORY. 1. Definitions

Vertex-Edge Graphs. Vertex-Edge Graphs In the Georgia Performance Standards. Sarah Holliday Southern Polytechnic State University

The Traveling Salesman Problem

Theory of Computing. Lecture 10 MAS 714 Hartmut Klauck

Lecture 5: Graphs. Rajat Mittal. IIT Kanpur

The Traveling Salesman Problem Outline/learning Objectives The Traveling Salesman Problem

Math 776 Graph Theory Lecture Note 1 Basic concepts

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 7

γ(ɛ) (a, b) (a, d) (d, a) (a, b) (c, d) (d, d) (e, e) (e, a) (e, e) (a) Draw a picture of G.

Discrete Mathematics for CS Spring 2008 David Wagner Note 13. An Introduction to Graphs

More NP-complete Problems. CS255 Chris Pollett May 3, 2006.

Graph Theory. 1 Introduction to Graphs. Martin Stynes Department of Mathematics, UCC January 26, 2011

Brief History. Graph Theory. What is a graph? Types of graphs Directed graph: a graph that has edges with specific directions

Junior Circle Meeting 3 Circuits and Paths. April 18, 2010

Graph (1A) Young Won Lim 4/19/18

GRAPHS, GRAPH MODELS, GRAPH TERMINOLOGY, AND SPECIAL TYPES OF GRAPHS

Adjacent: Two distinct vertices u, v are adjacent if there is an edge with ends u, v. In this case we let uv denote such an edge.

(Refer Slide Time: 01:00)

Eulerian tours. Russell Impagliazzo and Miles Jones Thanks to Janine Tiefenbruck. April 20, 2016

Grade 7/8 Math Circles Graph Theory - Solutions October 13/14, 2015

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao,David Tse Note 8

Introduction to Graph Theory

Precept 4: Traveling Salesman Problem, Hierarchical Clustering. Qian Zhu 2/23/2011

Best known solution time is Ω(V!) Check every permutation of vertices to see if there is a graph edge between adjacent vertices

Design and Analysis of Algorithms

Eulerian Tours and Fleury s Algorithm

1. a graph G = (V (G), E(G)) consists of a set V (G) of vertices, and a set E(G) of edges (edges are pairs of elements of V (G))

V1.0: Seth Gilbert, V1.1: Steven Halim August 30, Abstract. d(e), and we assume that the distance function is non-negative (i.e., d(x, y) 0).

Dieter Jungnickel (2008), Graphs, Networks and Algorithms, 3rd edition, which is available online via SpringerLink.

CHAPTER 10 GRAPHS AND TREES. Copyright Cengage Learning. All rights reserved.

Simple Graph. General Graph

v V Question: How many edges are there in a graph with 10 vertices each of degree 6?

Questions? You are given the complete graph of Facebook. What questions would you ask? (What questions could we hope to answer?)

Optimal tour along pubs in the UK

Approximation Algorithms

Intermediate Math Circles Wednesday, February 22, 2017 Graph Theory III

Lecture 1. 2 Motivation: Fast. Reliable. Cheap. Choose two.

Worksheet 28: Wednesday November 18 Euler and Topology

Lecture 8: The Traveling Salesman Problem

MATH 113 Section 9.2: Topology

Discrete mathematics

Travelling Salesman Problem. Algorithms and Networks 2015/2016 Hans L. Bodlaender Johan M. M. van Rooij

Combinatorics Summary Sheet for Exam 1 Material 2019

Math 443/543 Graph Theory Notes 2: Transportation problems

Notes for Lecture 24

Math 778S Spectral Graph Theory Handout #2: Basic graph theory

Traveling Salesman Problem. Algorithms and Networks 2014/2015 Hans L. Bodlaender Johan M. M. van Rooij

Major Themes. 14: Graph Traversals. The Bridges of Königsberg Puzzle. Dr Papalaskari 1. Graph traversals: Euler circuit/trail.

Eulerian Cycle (2A) Young Won Lim 4/26/18

Graph theory. Po-Shen Loh. June We begin by collecting some basic facts which can be proved via bare-hands techniques.

IE 102 Spring Routing Through Networks - 1

MAS 341: GRAPH THEORY 2016 EXAM SOLUTIONS

Section 3.4 Basic Results of Graph Theory

Finite Math A Chapter 6 Notes Hamilton Circuits

Graphs (MTAT , 6 EAP) Lectures: Mon 14-16, hall 404 Exercises: Wed 14-16, hall 402

Graphs and Puzzles. Eulerian and Hamiltonian Tours.

Major Themes. Graph Traversals. Euler s SoluWon to The Bridges of Königsberg. The Bridges of Königsberg Puzzle. Dr Papalaskari 1

Graphs. Pseudograph: multiple edges and loops allowed

Majority and Friendship Paradoxes

Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, Approximation Algorithms

Unit 8: Coping with NP-Completeness. Complexity classes Reducibility and NP-completeness proofs Coping with NP-complete problems. Y.-W.

Instant Insanity Instructor s Guide Make-it and Take-it Kit for AMTNYS 2006

Theorem 2.9: nearest addition algorithm

10/8/13 Comp 555 Fall

Chapter 1 Graph Theory

Traveling Salesperson Problem (TSP)

Transcription:

Euler and Hamilton paths Jorge A. Cobb The University of Texas at Dallas 1

Paths and the adjacency matrix The powers of the adjacency matrix A r (with normal, not boolean multiplication) contain the number of paths from v i to v j with exactly r edges Proof: By induction. True for A 1 = A. When we consider A r+1, the (i, j)-th entry there will be b i1 a 1j + b i2 a 2j +... + b in a nj where b ik are the entries in A r and a kj are the entries in A. So that entry will add the count of paths from all possible paths with r edges that can be extended to end at v j. 2

The bridges of Königsberg The town of Königsberg (East Prussia; now Kaliningrad, Russia) is divided in four sections with seven bridges Is it possible to start somewhere and return to that point crossing all bridges exactly once? 3

A graph for Königsberg We represent the four regions as vertices and the bridges as edges (rearranging because of isomorphism) 4

Euler circuits and paths An Euler circuit in a graph is a simple circuit containing every edge of the graph. An Euler path in a graph is a simple path containing every edge of the graph. Theorem 1: A finite graph has an Euler circuit if and only if it is connected and all vertices have even degree. 5

Proof: Only if direction Suppose that a graph has an Euler circuit. Then the graph must be connected. The Euler circuit starts at a vertex v. Every time any vertex other the last vertex in the circuit is entered (including v if it is visited multiple times), the circuit must leave this vertex. Thus, the edges entering and leaving each vertex are paired, adding 2 to that vertex s degree each time it is visited. 2 is also added to v s degree for the first and last edge, so all vertex degrees are even. 6

Proof: If direction Suppose that all vertices have even degrees. We construct an Euler circuit as follows: Start at an arbitrary vertex, and construct a path randomly, until we can t do so anymore (this will happen at some point because the graph is finite). This process must terminate at v, because each time the path passes from a vertex u it subtracts 2 from the remaining edges incident to u, and those are an even number. Therefore, we can always leave any vertex other than v. 7

Proof: If direction We have therefore constructed a simple circuit. Does this use all edges? If not, consider the subgraphs obtained by deleting the circuit we just constructed. Because the original graph is connected, these subgraphs will have at least a vertex in common with our path. Follow the above process in each such subgraph, and splice the circuits together to obtain an Euler circuit for the original graph. 8

Assume you started at a You get stuck once you go back to a. 9

Euler paths Theorem 2: A finite graph has an Euler path (but not an Euler circuit) if and only if it is connected and exactly two vertices have odd degrees. Proof: Analogous to Theorem 1. The two vertices with the odd degrees must be the first and last vertices in the Euler path (see the book for details) 10

The bridges of Königsberg Is there an Euler circuit or path? NO because all four vertices have odd degree Modern Königsberg Two brigdes were destroyed by British bombers in WW II. Two bridges were replaced by a highway by the Russians. Three bridges plus the highway remain The graph has now two vertices with degree 2 and two with degree 3, so it has an Euler path 11

Extensions of the problem Identified regions The blue prince wants to be able to visit all bridges starting at his castle and ending at the inn. Which new bridge should he build? 12

Solution We need an Euler path from the blue castle to the inn. We have the following degrees: blue castle, red castle, and church: 3 inn: 5 We need to make the degrees of the red castle and church even build a bridge between them 13

More extensions The red prince, furious with the previous development, wants to build a ninth bridge so that he can go from his castle to the inn and the blue prince can no longer do so. The bishop, upset with all this bridge building and the excessive drinking, wants to build a tenth bridge so that everybody can go home (i.e., there is an Euler circuit). 14

Hamilton circuits and paths A Hamilton circuit (path) is a simple circuit (path) that contains all vertices and passes through each vertex of the graph exactly once. How can we tell if a graph has a Hamilton circuit or path? Not easily, i.e., in general, in not less than exponential time in the number of vertices There are some tests that can exclude graphs (e.g., no vertex of degree one for circuits). 15

Ham. Circuits and Paths 16

Number of Hamilton paths Consider the complete graph K n with n > 2. How many Hamilton circuits are there? Select any vertex as the start vertex (because all vertices will belong to the circuit the choice doesn t matter). From this vertex we can choose n-1 successor vertices, from each of them n-2 vertices, and so on, for a total of (n-1)! circuits. Because direction doesn t matter, the distinct circuits are (n- 1)!/2. 17

Weighted graphs A weighted graph is a graph where numbers (weights or costs) have been attached to each edge. Example: In a graph for flight connections, weights could represent time needed for each flight, distance traveled, or cost of traveling on that flight. In a computer network, costs could represent the delay for a message to travel through a link. 18

Path length In a graph without weights, we define the length of a path as the number of edges in it. In a weighted graph, the path length is a function of the weights of the edges in the path, usually the sum of those weights. 19

The Traveling Salesman problem A traveling salesman needs to visit n cities, going to each city exactly once, and return to his starting city. Assume every city is connected to every other city, but the cost of traveling differs for each city pair. What is the sequence of cities that minimizes the overall cost? Equivalent formulation: Find the Hamilton circuit in K n with shortest length. 20

Solving the TSP No algorithm is known that will guarantee finding the best solution except by examining all possible circuits (or equivalent approaches). For n = 25, (n 1)! / 2 = 24! / 2 3 10 23. If we take one nanosecond to calculate the cost of each circuit, we still need 3 10 14 seconds, or about 10 million years. The problem is provably NP-complete. 21

TSP Problems Planning routes 980 cities in Luxembourg 24,978 cities in Sweden (solved May 2004) 1,904,711 cities in the world Drilling printed circuit boards cost of moving the drill and possibly changing drills because of different hole sizes Genome sequencing edges represent likelihood that a fragment of DNA follows another fragment 22

Example tour on circuit board 3,038 points to visit 23

Exact methods for TSP We can find exact solutions with techniques that remember previous partial results and reuse them rather than redoing the work. Techniques from linear programming are applicable here. For example, the optimal tour of 33,810 points on a circuit board was found in 2005 using multiple computers and a total of only 15.7 CPU-years. 24

Approximate solutions Reasonably fast algorithms that guarantee an error bound, i.e., a solution with cost at most c times of the original cost We can achieve c = 1.5 if the costs obey the triangle inequality, i.e., d(a, C) d(a, B) + d(b, C) guarantee an error bound with certain probability, typically 97%-98% Based on random walks and Markov chains do not guarantee anything, but are likely to produce a reasonable solution Greedy algorithms 25