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

Slides:



Advertisements
Similar presentations
Great Theoretical Ideas in Computer Science for Some.
Advertisements

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,
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.
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.
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.
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.
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.
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.
Can you connect the dots as shown without taking your pen off the page or drawing the same line twice.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
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.
Graphs, Puzzles, & Map Coloring
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
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.
Graph theory and networks. Basic definitions  A graph consists of points called vertices (or nodes) and lines called edges (or arcs). Each edge joins.
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.
Great Theoretical Ideas in Computer Science for Some.
COMPSCI 102 Introduction to Discrete Mathematics.
1 GRAPH Learning Outcomes Students should be able to: Explain basic terminology of a graph Identify Euler and Hamiltonian cycle Represent graphs using.
Programming Abstractions Cynthia Lee CS106B. Upcoming Topics Graphs! 1.Basics  What are they? How do we represent them? 2.Theorems  What are some things.
Graphs. Representations of graphs : undirected graph An undirected graph G have five vertices and seven edges An adjacency-list representation of G The.
Theory of Computational Complexity Probability and Computing Chapter Hikaru Inada Iwama and Ito lab M1.
An Introduction to Graph Theory
Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)
Outline 1 Properties of Planar Graphs 5/4/2018.
CSNB 143 Discrete Mathematical Structures
Çizge Algoritmaları.
Graphs: Definitions and Basic Properties
Applied Discrete Mathematics Week 13: Graphs
Graphs Hubert Chan (Chapter 9) [O1 Abstract Concepts]
CSE 373, Copyright S. Tanimoto, 2001 Graphs 1 -
Chapters 8.1 and 8.2 Based on slides by Y. Peng University of Maryland
Euler Paths and Circuits
Eulerian tours Miles Jones MTThF 8:30-9:50am CSE 4140 August 15, 2016.
Agenda Lecture Content: Introduction to Graph Path and Cycle
Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)
EECS 203 Lecture 20 More Graphs.
Great Theoretical Ideas in Computer Science
Discrete Maths 9. Graphs Objective
Discrete Mathematics for Computer Science
CSE 421: Introduction to Algorithms
Can you draw this picture without lifting up your pen/pencil?
Introduction to Graph Theory Euler and Hamilton Paths and Circuits
Graphs Chapter 13.
CSE 373, Copyright S. Tanimoto, 2002 Graphs 1 -
Chapters 8.1 and 8.2 Based on slides by Y. Peng University of Maryland
Discrete Math II Howon Kim
Route Inspection Which of these can be drawn without taking your pencil off the paper and without going over the same line twice? If we introduce a vertex.
Let us switch to a new topic:
Euler and Hamilton Paths
Discrete Mathematics for Computer Science
Applied Combinatorics, 4th Ed. Alan Tucker
Chapter 10 Graphs and Trees
Planarity.
Prof. Ramin Zabih Graph Traversal Prof. Ramin Zabih
Graph Theory Proof In Class Exercise.
Presentation transcript:

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

Today’s Topics: Graphs Some theorems on graphs Eulerian graphs You will study graphs in depth in CSE21 Today I just want to show you the basics

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

The Internet graph

Facebook graph

San diego road graph

Graph terminology The fruits are the Graphs Vertices Edges Loops None/other/more than one

Graph terminology The arrows are the Graphs Vertices Edges Loops None/other/more than one

Graph terminology Is this graph Undirected Directed Both Neither None/other/more than one

Graph terminology Which of the following is not a correct graph A. B. 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)

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

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 Each vertex v has degree(v) edges adjacent to it, so this list has sum of degrees many elements 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.

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? Yes No

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 Yes No

Eulerian graphs How can we check if a graph is Eulerian? Check all possible paths Stare and guess Be brave and do some math

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 ?

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

Proving 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

Proving Euler’s theorem: necessary part Proof of Euler’s theorem (necessary part): Let G be a graph with an Euler path: v1,v2,v3,….,vk where (vi,vi+1) are edges in G; vertices may appear more than once; and each edge of G is accounted for exactly once.

Proving Euler’s theorem: necessary part Proof of Euler’s theorem (necessary part): Let G be a graph with an Euler path: v1,v2,v3,….,vk where (vi,vi+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,5 3 2 4 1 5

Proving Euler’s theorem: necessary part Proof of Euler’s theorem (necessary part): Let G be a graph with an Euler path: v1,v2,v3,….,vk where (vi,vi+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 v1 or vk), we count 2 edges in the path (one going in and one going out). So, any vertex which is not v1 or vk 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.

Proving 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)

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

Example 3 2 4 Creating a path 1 5 6

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

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

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

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

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

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

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

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

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

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 v1,v2,….,vk with v1vk. Say vk occurred n0 previous times in the path. Then we visited 2n+1 edges touching vk. Since all the degrees are even, there is still some edge touching vk which we didn’t traverse. Hence, the algorithm cannot stop with vk. QED

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

Proving Euler’s theorem: sufficient part Claim: if the path started with v1, it must end with v1 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

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