Graphs and Puzzles. Eulerian and Hamiltonian Tours.

Similar documents
Eulerian Tours and Fleury s Algorithm

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

Introduction to Graphs

Master Theorem, Introduction to Graphs

Introduction to Graphs

Eulerian Tours and Fleury s Algorithm

Notes slides from before lecture. CSE 21, Winter 2017, Section A00. Lecture 9 Notes. Class URL:

DNA Sequencing The Shortest Superstring & Traveling Salesman Problems Sequencing by Hybridization

10/15/2009 Comp 590/Comp Fall

10/8/13 Comp 555 Fall

CSCI2950-C Lecture 4 DNA Sequencing and Fragment Assembly

Sequence Assembly Required!

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

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

Undirected Network Summary

DNA Sequencing. Overview

Graph Algorithms in Bioinformatics

Algorithms for Bioinformatics

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

Notes slides from before lecture. CSE 21, Winter 2017, Section A00. Lecture 10 Notes. Class URL:

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

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

EECS 203 Lecture 20. More Graphs

Sequencing. Computational Biology IST Ana Teresa Freitas 2011/2012. (BACs) Whole-genome shotgun sequencing Celera Genomics

Fundamental Properties of Graphs

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

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

Algorithms for Bioinformatics

An Introduction to Graph Theory

BMI/CS 576 Fall 2015 Midterm Exam

Elements of Graph Theory

Varying Applications (examples)

MATH 101: Introduction to Contemporary Mathematics

Chapter 11: Graphs and Trees. March 23, 2008

Genome Reconstruction: A Puzzle with a Billion Pieces Phillip E. C. Compeau and Pavel A. Pevzner

Introduction to Graphs

Characterizing Graphs (3) Characterizing Graphs (1) Characterizing Graphs (2) Characterizing Graphs (4)

Characterization of Graphs with Eulerian Circuits

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

13. (a) G,G. A circuit of length 1 is a loop. 14. (a) E,E. (c) A,B,C,A. 16. (a) BF, FG

Walking with Euler through Ostpreußen and RNA

Chapter 8 Topics in Graph Theory

WUCT121. Discrete Mathematics. Graphs

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

Graph Theory

Graphs. Pseudograph: multiple edges and loops allowed

6.2. Paths and Cycles

MATH 113 Section 9.2: Topology

Chapter 2 Graphs. 2.1 Definition of Graphs

UCSD CSE 101 MIDTERM 1, Winter 2008

Introduction to Graphs

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

Packet #6: Counting & Graph Theory. Applied Discrete Mathematics

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

Graph Theory CS/Math231 Discrete Mathematics Spring2015

Section 8.2 Graph Terminology. Undirected Graphs. Definition: Two vertices u, v in V are adjacent or neighbors if there is an edge e between u and v.

Introduction III. Graphs. Motivations I. Introduction IV

Chapter 14 Section 3 - Slide 1

Read Mapping. de Novo Assembly. Genomics: Lecture #2 WS 2014/2015

Graph and Digraph Glossary

Genome 373: Genome Assembly. Doug Fowler

Math 110 Graph Theory II: Circuits and Paths

Math 776 Graph Theory Lecture Note 1 Basic concepts

Math.3336: Discrete Mathematics. Chapter 10 Graph Theory

Excursions in Modern Mathematics Sixth Edition. Chapter 5 Euler Circuits. The Circuit Comes to Town. Peter Tannenbaum

An Introduction to Graph Theory

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 7

Logic: The Big Picture. Axiomatizing Arithmetic. Tautologies and Valid Arguments. Graphs and Trees

Artificial Intelligence

Sarah Will Math 490 December 2, 2009

Graph Algorithms in Bioinformatics

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?

Topics Covered. Introduction to Graphs Euler s Theorem Hamiltonian Circuits The Traveling Salesman Problem Trees and Kruskal s Algorithm

Lecture 5: Graphs. Graphs! Euler Definitions: model. Fact! Euler Again!! Planar graphs. Euler Again!!!!

Graph Theory. Part of Texas Counties.

Eulerian Cycle (2A) Walk : vertices may repeat, edges may repeat (closed or open) Trail: vertices may repeat, edges cannot repeat (open)

Sections 5.2, 5.3. & 5.4

2. CONNECTIVITY Connectivity

Assignment 4 Solutions of graph problems

Section Graphs, Paths, and Circuits. Copyright 2013, 2010, 2007, Pearson, Education, Inc.

TWO CONTRIBUTIONS OF EULER

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis

DNA Fragment Assembly

CS70 - Lecture 6. Graphs: Coloring; Special Graphs. 1. Review of L5 2. Planar Five Color Theorem 3. Special Graphs:

Ma/CS 6a Class 8: Eulerian Cycles

BIL694-Lecture 1: Introduction to Graphs

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

Introduction to Graph Theory

Discrete Mathematics and Probability Theory Fall 2013 Midterm #2

Outline. Graphs. Divide and Conquer.

Decision Problems. Observation: Many polynomial algorithms. Questions: Can we solve all problems in polynomial time? Answer: No, absolutely not.

Sequence Assembly. BMI/CS 576 Mark Craven Some sequencing successes

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.

Graph Theory. Defining a Graph

Let G = (V, E) be a graph. If u, v V, then u is adjacent to v if {u, v} E. We also use the notation u v to denote that u is adjacent to v.

Grades 7 & 8, Math Circles 31 October/1/2 November, Graph Theory

a) Graph 2 and Graph 3 b) Graph 2 and Graph 4 c) Graph 1 and Graph 4 d) Graph 1 and Graph 3 e) Graph 3 and Graph 4 f) None of the above

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

Design and Analysis of Algorithms

Week 11: Eulerian and Hamiltonian graphs; Trees. 15 and 17 November, 2017

Transcription:

Graphs and Puzzles. Eulerian and Hamiltonian Tours. CSE21 Winter 2017, Day 11 (B00), Day 7 (A00) February 3, 2017 http://vlsicad.ucsd.edu/courses/cse21-w17

Exam Announcements Seating Chart on Website Good luck! Exam on Monday Covers through Day 9 (no graphs) Bring student ID. One handwritten note sheet (8.5 x 11, both sides). Look up seat assignment. No calculators. No blue books. Review Session covering the Practice Midterm Tomorrow 1-3pm Sunday noon-2pm

Representing directed graphs Adjacency list (list of lists): for each vertex v, associate list of all neighbors of v. Rosen p. 668

Neighbors The neighbors of a vertex v are all the vertices w for which there is an edge whose endpoints are v,w. If two vertices are neighbors then they are called adjacent to one another. Rosen p. 651

Degree The degree of a vertex in an undirected graph is the total number of edges incident with it, except that a loop contributes twice. What's the maximum degree of a vertex in this graph? A. 0. B. 1 C. 2 D. 3 E. None of the above. Rosen p. 652

What's the degree of vertex 5? A. 5 B. 3 C. 2 D. 1 E. None of the above. Degree

What's the degree of vertex 0? A. 5 B. 3 C. 2 D. 1 E. None of the above. Degree

Handshakes If there are n people in a room, and each shakes hands with d people, how many handshakes take place? A. n B. d C. nd D. (nd)/2 E. None of the above.

Handshakes If there are n people in a room, and each shakes hands with d people, how many handshakes take place? A. n B. d C. nd D. (nd)/2 E. None of the above. Don't double-count each handshake!

Handshakes "in" graphs If a simple graph has n vertices and each vertex has degree d, how many edges are there? 2 E = n*d

Handshakes in graphs If any graph has n vertices, then 2 E = sum of degrees of all vertices

Handshakes "in" graphs If any graph has n vertices, then 2 E = sum of degrees of all vertices What can we conclude? A. Every degree in the graph is even. B. The number of edges is even. C. The number of vertices with odd degree is even. D. The number self loops is even. E. None of the above.

Recall: What is a graph? A (directed) graph G is A nonempty set of vertices V, also called nodes and A set of edges E, each pointing from one (tail) vertex to another (head) vertex. (A directed edge is denoted with an arrow ) head tail

Tartaglia's Pouring Problem Large cup: contains 8 ounces, can hold more. Medium cup: is empty, has 5 ounce capacity. Small cup: is empty, has 3 ounce capacity You can pour from one cup to another until the first is empty or the second is full. Can we divide the coffee in half? How?

Tartaglia's Pouring Problem Large cup: contains 8 ounces, can hold more. Medium cup: is empty, has 5 ounce capacity. Small cup: is empty, has 3 ounce capacity You can pour from one cup to another until the first is empty or the second is full. Can we divide the coffee in half? How? Hint: configurations (l,m,s) code # ounces in each cup

Tartaglia's Pouring Problem

Tartaglia's Pouring Problem Rephrasing the problem: Looking for path from (8,0,0) to (4,4,0)

Path Sequence (v 0, e 1, v 1, e 2, v 2,, e k, v k ) describes a route through the graph from Order matters! start vertex v 0 to end vertex v k

Tartaglia's Pouring Problem Rephrasing the problem: (1) Is there a path from (8,0,0) to (4,4,0)? (2) If so, what's the best path? "Best" means "shortest length"

What's the shortest length of a path from (8,0,0) to (4,4,0)? A. 7 B. 8 C. 14 D. 16 E. None of the above. Tartaglia's Pouring Problem

Algorithmic questions related to paths Reachability: // decision Does there exist a path from vertex v to vertex w? Path: // construction Find a path from vertex v to vertex w. Distance: // optimization What s the length of the shortest path from vertex v to vertex w?

Seven Bridges of Konigsberg Is there a path that crosses each bridge (exactly) once? A. Yes B. No Rosen p. 693

Seven Bridges of Konigsberg Observe: exact location on the north side doesn't matter because must come & go via a bridge. Can represent each bridge as an edge.

Seven Bridges of Konigsberg Is there a path where each edge occurs exactly once? Euler (or, Eulerian) tour Rosen p. 693

Seven Bridges of Konigsberg redux Which of these figures can you draw without lifting your pencil off the paper and without retracing any edge of the figure? A. C. B. D.

Algorithmic questions related to Euler tours Existence: Does the given graph G contain an Euler tour? Path: Find an Euler tour for the given graph G, if possible. Turns out there are great algorithms for each of these next!

Algorithmic questions related to Euler tours Hamiltonian tours A Hamiltonian tour is a path where each vertex occurs exactly once. Existence: Does the given graph G contain a Hamiltonian tour? Path: Find a Hamiltonian tour for the given graph G, if possible. These questions turn out to be intractable!!!

Algorithmic questions related to Euler tours Hamiltonian tours Actually, it is not known how to determine in any reasonable amount of time whether a graph G has a Hamiltonian Tour, or how to find one. An Opportunity: You can earn $1,000,000 if you can give an algorithm that finds a Hamiltonian Tour (if one exists) in an arbitrary graph on n vertices that takes time O(n k ) for some constant k.

Light Switches A light bulb is connected to 3 switches in such a way that it lights up only when all the switches are in the proper position. But you don't know what the proper position of each switch is! All the switches are down. How many times must you press a switch if you want to guarantee that the light bulb will turn on? A. 4 B. 7 C. 8 D. 16

Light Switches Configuration 1 if switch is UP, 0 if DOWN Connect configuration if off by one switch. Rephrasing the problem: Looking for Hamiltonian tour through graph. (starting at the 000 vertex)

Our Strategy Puzzle / Problem Model as a graph Choose vertex set & edge set sometimes many possible options Use graph algorithms to solve puzzle / problem

DNA Reconstruction Problem Given collection of short DNA strings. Find longer DNA string that includes them all. Many possible formulations as a graph problem. Successful solution was a big step in Human Genome Project.

Given collection of short DNA strings. S = { ATG, AGG, TGC, TCC, GTC, GGT, GCA, CAG } Find longer DNA string that includes them all. Vertex set: Edge set: DNA Reconstruction: as a Hamiltonian tour

DNA Reconstruction: as a Hamiltonian tour Given collection of short DNA strings. S = { ATG, AGG, TGC, TCC, GTC, GGT, GCA, CAG } Find longer DNA string that includes them all. Vertex set: S, i.e. a vertex for each short DNA string Edge set: edge from v to w if the first two letters of w equal the last two letters of v ATG AGG TGC TCC GTC GGT GCA CAG

DNA Reconstruction: as a Hamiltonian tour Given collection of short DNA strings. S = { ATG, AGG, TGC, TCC, GTC, GGT, GCA, CAG } Find longer DNA string that includes them all. Vertex set: S, i.e. a vertex for each short DNA string Edge set: edge from v to w if the first two letters of w equal the last two letters of v ATG AGG TGC TCC GTC GGT GCA CAG What's a Hamiltonian tour?

Given collection of short DNA strings. S = { ATG, AGG, TGC, TCC, GTC, GGT, GCA, CAG } Find longer DNA string that includes them all. Vertex set: Edge set: DNA Reconstruction: as an Eulerian tour

DNA Reconstruction: as an Eulerian tour Given collection of short DNA strings. S = { ATG, AGG, TGC, TCC, GTC, GGT, GCA, CAG } Find longer DNA string that includes them all. Vertex set: All length-two strings that appear in a word in S Edge set: edge from ab to bc if abc is in S. AG GG CA AT TG GC TC GT CC What's an Eulerian tour?

Note: Other classes may use terminology whereby tour = cycle = circuit Algorithmic questions related to tours An Eulerian tour is a path where each edge occurs exactly once. - Eulerian cycle: Eulerian tour that starts and ends at same vertex. A Hamiltonian tour is a path where each vertex occurs exactly once. - Hamiltonian cycle: Ham. tour that starts and ends at same vertex. Which is true of the graph to the right? A. There's only one Eulerian cycle in this graph. B. There's no Hamiltonian tour in this graph. C. Each Hamiltonian tour is an Eulerian cycle. D. None of the above. E. More than one of the above.

Number of Paths How many paths are there between vertex A and vertex B? A. None. B. Exactly one. C. Exactly two. D. More than two. E. None of the above.

Number of Paths How many paths are there between vertex A and vertex G? A. None. B. Exactly one. C. Exactly two. D. More than two. E. None of the above.

Number of Paths How many paths are there between vertex A and vertex I? A. None. B. Exactly one. C. Exactly two. D. More than two. E. None of the above.

Connectedness An undirected graph G is connected if for any ordered pair of vertices (v,w) there is a path from v to w. Connected Not connected

Connectedness An undirected graph G is connected if for any ordered pair of vertices (v,w) there is a path from v to w. An undirected graph G is disconnected if A. For any ordered pair of vertices (v,w) there is no path from v to w. B. There is an ordered pair of vertices (v,w) with a path from v to w. C. There is an ordered pair of vertices (v,w) with no path from v to w. D. For every ordered pair of vertices (v,w) there is a path from v to w. E. None of the above.

Connected Components Disconnected graphs can be broken up into pieces where each is connected. Each (maximal) connected piece of the graph is a connected component. maximal means that if you make it any larger, it will lose the given (in this case, connected ) property.

Exam Announcements Seating Chart on Website Good luck! Exam on Monday Covers through Day 9 (no graphs) Bring student ID. One handwritten note sheet (8.5 x 11, both sides). Look up seat assignment. No calculators. No blue books. Review Session covering the Practice Midterm Tomorrow 1-3pm Sunday noon-2pm