CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.

Slides:



Advertisements
Similar presentations
CSE 211 Discrete Mathematics
Advertisements

Great Theoretical Ideas in Computer Science
Great Theoretical Ideas in Computer Science for Some.
Chapter 8 Topics in Graph Theory
Tutorial 5 of CSCI2110 Eulerian Path & Hamiltonian Cycle Tutor: Zhou Hong ( 周宏 )
Lecture 5 Graph Theory. Graphs Graphs are the most useful model with computer science such as logical design, formal languages, communication network,
MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta
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.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 – CHAPTER 4 GRAPHS 1.
Graph-02.
Bayesian Networks, Winter Yoav Haimovitch & Ariel Raviv 1.
Introduction to Graphs
Great Theoretical Ideas in Computer Science for Some.
CompSci 102 Discrete Math for Computer Science April 19, 2012 Prof. Rodger Lecture adapted from Bruce Maggs/Lecture developed at Carnegie Mellon, primarily.
1 Lecture 5 (part 2) Graphs II Euler and Hamiltonian Path / Circuit Reading: Epp Chp 11.2, 11.3.
CSE 20 – Discrete Mathematics Dr. Cynthia Bailey Lee Dr. Shachar Lovett Peer Instruction in Discrete Mathematics by Cynthia Leeis licensed under a Creative.
CSE 20 – Discrete Mathematics Dr. Cynthia Bailey Lee Dr. Shachar Lovett Peer Instruction in Discrete Mathematics by Cynthia Leeis licensed under a Creative.
Great Theoretical Ideas in Computer Science.
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.
Math Foundations Week 12 Graphs (2). Agenda Paths Connectivity Euler paths Hamilton paths 2.
4/17/2017 Section 8.5 Euler & Hamilton Paths ch8.5.
Chapter 11 Graphs and Trees This handout: Terminology of Graphs Eulerian Cycles.
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.
GRAPH Learning Outcomes Students should be able to:
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
5.1  Routing Problems: planning and design of delivery routes.  Euler Circuit Problems: Type of routing problem also known as transversability problem.
CSE 20 – Discrete Mathematics Dr. Cynthia Bailey Lee Dr. Shachar Lovett Peer Instruction in Discrete Mathematics by Cynthia Leeis licensed under a Creative.
CS106X – Programming Abstractions in C++ Cynthia Bailey Lee BFS animation slides by Keith Schwarz CS2 in C++ Peer Instruction Materials by Cynthia Bailey.
Which of these can be drawn without taking your pencil off the paper and without going over the same line twice? If we can find a path that goes over all.
Can you connect the dots as shown without taking your pen off the page or drawing the same line twice.
CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
Graphs.  Definition A simple graph G= (V, E) consists of vertices, V, a nonempty set of vertices, and E, a set of unordered pairs of distinct elements.
CSE 20 – Discrete Mathematics Dr. Cynthia Bailey Lee Dr. Shachar Lovett Peer Instruction in Discrete Mathematics by Cynthia Leeis licensed under a Creative.
Graphs, Puzzles, & Map Coloring
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
Lecture 10: Graph-Path-Circuit
Introduction to Graphs. This Lecture In this part we will study some basic graph theory. Graph is a useful concept to model many problems in computer.
Shortest Path Based Sufficiency Condition for Hamiltonian Graphs
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.
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.
MAT 2720 Discrete Mathematics Section 8.2 Paths and Cycles
Chapter 11 - Graph CSNB 143 Discrete Mathematical Structures.
Great Theoretical Ideas in Computer Science for Some.
COMPSCI 102 Introduction to Discrete Mathematics.
Approximation Algorithms by bounding the OPT Instructor Neelima Gupta
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
1 GRAPH Learning Outcomes Students should be able to: Explain basic terminology of a graph Identify Euler and Hamiltonian cycle Represent graphs using.
1 Lecture 5 (part 2) Graphs II (a) Circuits; (b) Representation Reading: Epp Chp 11.2, 11.3
Programming Abstractions Cynthia Lee CS106B. Upcoming Topics Graphs! 1.Basics  What are they? How do we represent them? 2.Theorems  What are some things.
رياضيات متقطعة لعلوم الحاسب MATH 226. Chapter 10.
An Introduction to Graph Theory
Eulerian tours Miles Jones MTThF 8:30-9:50am CSE 4140 August 15, 2016.
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?
Discrete Math II Howon Kim
Euler and Hamilton Paths
Discrete Mathematics for Computer Science
Applied Combinatorics, 4th Ed. Alan Tucker
Presentation transcript:

CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett

Today’s Topics: 1. Graphs 2. Some theorems on graphs 3. Eulerian graphs 2

Graphs  Model relations between pairs of objects  Basic ingredient in many algorithms: Network routing, GPS guidance, Simulation of chemical reactions,… 3

The Internet graph 4

Facebook graph 5

San diego road graph 6

Graph terminology  The fruits are the A. Graphs B. Vertices C. Edges D. Loops E. None/other/more than one 7

Graph terminology  The arrows are the A. Graphs B. Vertices C. Edges D. Loops E. None/other/more than one 8

Graph terminology  Is this graph A. Undirected B. Directed C. Both D. Neither E. None/other/more than one 9

Graph terminology  Which of the following is not a correct graph 10 A.B.C. D. None/other/more than one

Our first graph theorem  We already saw a theorem about graphs!  Recall: in any group of 6 people, either there are 3 that form a club, or 3 that are strangers  Any graph with 6 vertices contains either a triangle (3 vertices all connected) or an empty triangle (3 vertices not connected) 11

Our second graph theorem  Let G be an undirected graph  Degree of a vertex – number of edges adjacent to it (e.g. touch it)  Denote it by degree(v)  Theorem: in any undirected graph without loops, the sum of all the degrees is even  Try and prove yourself first 12

Our second graph theorem  Theorem: in any undirected graph, the sum of all the degrees is even  Proof: Consider pairs (v,e) with v a vertex and e an edge adjacent to it. Create a list of all such pairs. How many elements this list has? We calculate it in two ways 1. Each vertex v has degree(v) edges adjacent to it, so this list has sum of degrees many elements 2. Each edge has 2 vertices adjacent to it, so this list has twice the number of edges many elements So, sum of degrees = twice the number of edges, hence it must be even. QED. 13

Eulerian graphs  Let G be an undirected graph  A graph is Eulerian if it can drawn without lifting the pen and without repeating edges  Is this graph Eulerian? A. Yes B. No 14

Eulerian graphs  Let G be an undirected graph  A graph is Eulerian if it can drawn without lifting the pen and without repeating edges  What about this graph A. Yes B. No 15

Eulerian graphs  How can we check if a graph is Eulerian? A. Check all possible paths B. Stare and guess C. Be brave and do some math 16

Eulerian graphs  Degree of a vertex: number of edges adjacent to it  Euler’s theorem: a connected graph is Eulerian iff the number of vertices with odd degrees is either 0 or 2  Does it work for and ? 17

Proving Euler’s theorem  Euler’s theorem gives a necessary and sufficient condition for a connected graph to be Eulerian  All degrees are even  Two degrees odd, rest are even  Will prove this  Will see how algorithmic thinking is useful 18

Proving Euler’s theorem: necessary part  Euler’s theorem (necessary part): If a connected graph G is Eulerian then all degrees are even; or two degrees are odd and rest are even Try to prove it first yourself 19

Proving Euler’s theorem: necessary part  Proof of Euler’s theorem (necessary part): Let G be a graph with an Euler path: v 1,v 2,v 3,….,v k where (v i,v i+1 ) are edges in G; vertices may appear more than once; and each edge of G is accounted for exactly once. 20

Proving Euler’s theorem: necessary part  Proof of Euler’s theorem (necessary part): Let G be a graph with an Euler path: v 1,v 2,v 3,….,v k where (v i,v i+1 ) are edges in G; vertices may appear more than once; and each edge of G is accounted for exactly once. For example, if G= path=1,2,3,4,5,2,4,1,

Proving Euler’s theorem: necessary part  Proof of Euler’s theorem (necessary part): Let G be a graph with an Euler path: v 1,v 2,v 3,….,v k where (v i,v i+1 ) are edges in G; vertices may appear more than once; and each edge of G is accounted for exactly once. The degree of a vertex of G is the number of edges it has. For any internal vertex in the path (eg not v 1 or v k ), we count 2 edges in the path (one going in and one going out). So, any vertex which is not v 1 or v k must have an even degree. If v1  vk then both have odd degrees. If v1=vk is the same vertex then it also has even degree. QED. 22

Proving Euler’s theorem: sufficient part  Euler’s theorem (sufficient part): If G is a connected graph with all degrees even, then G is Eulerian (we won’t show this here, but the proof can be extended to the case where exactly two degrees are odd, and the rest are even) 23

Proving Euler’s theorem: sufficient part  Euler’s theorem (sufficient part): If G is a connected graph with all degrees even, then G is Eulerian  Let v 1 be an arbitrary start vertex  Create a path v 1,v 2,…,v k using the following algorithm:  If there exists a vertex v k+1 such that the edge (v k,v k+1 ) was not visited yet, add v k+1 to the path  Repeat 24

Example  Creating a path

Example  Creating a path  Say we choose v 1 =1  1,

Example  Creating a path  Say we choose v 1 =1  1,2,

Example  Creating a path  Say we choose v 1 =1  1,2,3,

Example  Creating a path  Say we choose v 1 =1  1,2,3,4,

Example  Creating a path  Say we choose v 1 =1  1,2,3,4,1,

Example  Creating a path  Say we choose v 1 =1  1,2,3,4,1,6,

Example  Creating a path  Say we choose v 1 =1  1,2,3,4,1,6,5,

Example  Creating a path  Say we choose v 1 =1  1,2,3,4,1,6,5,

Proving Euler’s theorem: sufficient part  Assumption: all degrees are even  Claim: if the path started with v 1, it must end with v 1  Try and prove it yourself first 34

Proving Euler’s theorem: sufficient part  Assumption: all degrees are even  Claim: start and end vertex are the same  Proof: by contradiction.  Assume that the path the algorithm creates is v 1,v 2,….,v k with v 1  v k.  Say v k occurred n  0 previous times in the path.  Then we visited 2n+1 edges touching v k.  Since all the degrees are even, there is still some edge touching v k which we didn’t traverse.  Hence, the algorithm cannot stop with v k. QED 35

Proving Euler’s theorem: sufficient part  Claim: if the path started with v 1, it must end with v 1  Problem: maybe this path doesn’t cover all edges in the graph  E.g. path 1,2,3,4,1,6,5,

Proving Euler’s theorem: sufficient part  Claim: if the path started with v 1, it must end with v 1  Problem: maybe this path doesn’t cover all edges in the graph  Solution (proof idea):  Remove edges in path from graph  Remaining degrees are still even  Find another path  Connect it to original path  Continue until all edges covered 37

Example  Creating a path  Say we choose v 1 =1  Cycle 1:1,2,3,4,1,6,5,1  Cycle 2: 2,4,5,2  Combined cycle: 1,2,4,5,2,3,4,1,6,5,