Math Foundations Week 12 Graphs (2). Agenda Paths Connectivity Euler paths Hamilton paths 2.

Slides:



Advertisements
Similar presentations
CSE 211 Discrete Mathematics
Advertisements

CS 336 March 19, 2012 Tandy Warnow.
Great Theoretical Ideas in Computer Science for Some.
Chapter 8 Topics in Graph Theory
Chapter 9 Graphs.
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.
22C:19 Discrete Math Graphs Fall 2014 Sukumar Ghosh.
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.
 期中测验时间:本周五上午 9 : 40  教师 TA 答疑时间 : 周三晚上 6 : 00—8 : 30  地点:软件楼 315 房间,  教师 TA :李弋老师  开卷考试.
Introduction to Graphs
MCA 520: Graph Theory Instructor Neelima Gupta
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.
SE561 Math Foundations Week 11 Graphs I
Graph Theory in CS Route Search in Online Map Services
Copyright © Zeph Grunschlag, Paths and Connectivity Zeph Grunschlag.
Selected Topics in Data Networking Graph Representation.
Applied Discrete Mathematics Week 12: Trees
9.2 Graph Terminology and Special Types Graphs
GRAPH Learning Outcomes Students should be able to:
Graphs Chapter 10.
Graph Theoretic Concepts. What is a graph? A set of vertices (or nodes) linked by edges Mathematically, we often write G = (V,E)  V: set of vertices,
1 Graphs Chapters 9.1 and 9.2 University of Maryland Chapters 9.1 and 9.2 Based on slides by Y. Peng University of Maryland.
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 for Computer Science Prof. Shachar Lovett.
Based on slides by Y. Peng University of Maryland
Module #19: Graph Theory: part II Rosen 5 th ed., chs. 8-9.
GRAPHS THEROY. 2 –Graphs Graph basics and definitions Vertices/nodes, edges, adjacency, incidence Degree, in-degree, out-degree Subgraphs, unions, isomorphism.
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.
Week 11 - Monday.  What did we talk about last time?  Binomial theorem and Pascal's triangle  Conditional probability  Bayes’ theorem.
September1999 CMSC 203 / 0201 Fall 2002 Week #13 – 18/20/22 November 2002 Prof. Marie desJardins.
Unit – V Graph theory. Representation of Graphs Graph G (V, E,  ) V Set of vertices ESet of edges  Function that assigns vertices {v, w} to each edge.
Graph Theory and Applications
Lecture 10: Graph-Path-Circuit
Lecture 5.4: Paths and Connectivity CS 250, Discrete Structures, Fall 2011 Nitesh Saxena *Adopted from previous lectures by Zeph Grunschlag.
Vertex-Edge Graphs Euler Paths Euler Circuits. The Seven Bridges of Konigsberg.
Graph theory and networks. Basic definitions  A graph consists of points called vertices (or nodes) and lines called edges (or arcs). Each edge joins.
And before you really hate (mathematical) relations and begin to break your (social) relations, let’s switch to a new topic: Graphs Discrete Structures.
 Quotient graph  Definition 13: Suppose G(V,E) is a graph and R is a equivalence relation on the set V. We construct the quotient graph G R in the follow.
Basic properties Continuation
Chapter 11 - Graph CSNB 143 Discrete Mathematical Structures.
Chapter 9: Graphs.
Great Theoretical Ideas in Computer Science for Some.
Graphs Rosen, Chapter 8. NOT ONE OF THESE! One of these!
Week 11 - Wednesday.  What did we talk about last time?  Graphs  Paths and circuits.
Lecture 5.3: Graph Isomorphism and Connectivity CS 250, Discrete Structures, Fall 2011 Nitesh Saxena *Adopted from previous lectures by Zeph Grunschlag.
1. 期中测验时间和地点: 11 月 4 日, 上午 9:40—11 : 40 地点: 教室 2. 答疑时间和地点: 1)11 月 1 日 ( 周五 )13:00—15:00 软件楼 319 2)11 月 2 日和 3 日, 14:00—17:00 软件楼 3 楼 机房讨论室.
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
رياضيات متقطعة لعلوم الحاسب MATH 226. Chapter 10.
1 Graphs Chapters 10.1 and 10.2 University of Maryland Chapters 10.1 and 10.2 Based on slides by Y. Peng University of Maryland.
Graphs. Representations of graphs : undirected graph An undirected graph G have five vertices and seven edges An adjacency-list representation of G The.
An Introduction to Graph Theory
Lecture 5.4: Paths and Connectivity
Outline 1 Properties of Planar Graphs 5/4/2018.
Euler and Hamilton Cycles; Planar Graphs; Coloring.
Çizge Algoritmaları.
Graphs: Definitions and Basic Properties
Copyright © Zeph Grunschlag,
Eulerian tours Miles Jones MTThF 8:30-9:50am CSE 4140 August 15, 2016.
Can you draw this picture without lifting up your pen/pencil?
Graphs Chapter 13.
Discrete Math II Howon Kim
Lecture 5.3: Graph Isomorphism and Paths
Gaph Theory Planar Graphs
Applied Combinatorics, 4th Ed. Alan Tucker
Paths and Connectivity
Paths and Connectivity
Presentation transcript:

Math Foundations Week 12 Graphs (2)

Agenda Paths Connectivity Euler paths Hamilton paths 2

Paths A path in a graph is a continuous way of getting from one vertex to another by using a sequence of edges. EG: could get from 1 to 3 circuitously as follows: 1-e 1  2-e 1  1-e 3  3-e 4  2-e 6  2-e 5  2-e 4  e1e1 e3e3 e2e2 e4e4 e5e5 e6e6 e7e7

Paths DEF: A path of length n in an undirected graph is a sequence of n edges e 1, e 2, …,e n such that each consecutive pair e i, e i+1 share a common vertex. In a simple graph, one may instead define a path of length n as a sequence of n+1 vertices v 0, v 1, v 2, …,v n such that each consecutive pair v i, v i+1 are adjacent. Paths of length 0 are also allowed according to this definition. Q: Why does the second definition work for simple graphs? 4

Paths A: For simple graphs, any edge is unique between vertices so listing the vertices gives us the edge-sequence as well. DEF: A simple path contains no duplicate edges (though duplicate vertices are allowed). A cycle (or circuit) is a path which starts and ends at the same vertex. Note: Simple paths need not be in simple graphs. E.g., may contain loops. 5

Paths Q: Find a longest possible simple path in the following graph: e1e1 e3e3 e2e2 e4e4 e5e5 e6e6 e7e7

Paths A: The following path from 1 to 2 is a maximal simple path because simple: each of its edges appears exactly once maximal: because it contains every edge except the unreachable edge e 7 The maximal path: e 1,e 5,e 6,e 2,e 3,e e1e1 e3e3 e2e2 e4e4 e5e5 e6e6 e7e7

Paths in Directed Graphs One can define paths for directed graphs by insisting that the target of each edge in the path is the source of the next edge: DEF: A path of length n in a directed graph is a sequence of n edges e 1, e 2, …,e n such that the target of e i is the source e i+1 for each i. In a digraph, one may instead define a path of length n as a sequence of n+1 vertices v 0, v 1, v 2, …,v n such that for each consecutive pair v i, v i+1 there is an edge from v i to v i+1. 8

Paths in Directed Graphs Q: Consider digraph adjacency matrix: 1.Find a path from 1 to 4. 2.Is there a path from 4 to 1? 9

Paths in Directed Graphs A: 1.1  3  2  4. 2.There’s no path from 4 to 1. From 4 must go to 2, from 2 must stay at 2 or return to 4. In other words 2 and 4 are disconnected from 1. 10

Connectivity DEF: Let G be a pseudograph. Let u and v be vertices. u and v are connected to each other if there is a path in G which starts at u and ends at v. G is said to be connected if all vertices are connected to each other. 1. Note: Any vertex is automatically connected to itself via the empty path. 2. Note: A suitable definition for directed graphs will follow later. 11

Connectivity Q: Which of the following graphs are connected?

Connectivity A: First and second are disconnected. Last is connected

English Connectivity Puzzle Can define a puzzling graph G as follows: V = {3-letter English words} E : two words are connected if can get one word from the other by changing a single letter. One small subgraph of G is: Q: Is “fun” connected to “car” ? 14 jobrobjab

English Connectivity Puzzle A: Yes: fun  fan  far  car Or: fun  fin  bin  ban  bar  car 15

Connected Components DEF: A connected component (or just component) in a graph G is a set of vertices such that all vertices in the set are connected to each other and every possible connected vertex is included. Q: What are the connected components of the following graph?

Connected Components A: The components are {1,3,5},{2,4,6},{7} and {8} as one can see visually by pulling components apart:

N-Connectivity Not all connected graphs are created equal! Q: Rate following graphs in terms of their design value for computer networks: 1) 2) 3) 4) 18

N-Connectivity A: Want all computers to be connected, even if 1 computer goes down: 1) 2 nd best. However, there’s a weak link— “cut vertex” 2) 3 rd best. Connected but any computer can disconnect 3) Worst! Already disconnected 4) Best! Network dies only with 2 bad computers 19

N-Connectivity The network is best because it can only become disconnected when 2 vertices are removed. In other words, it is 2-connected. Formally: DEF: A connected simple graph with 3 or more vertices is 2-connected if it remains connected when any vertex is removed. When the graph is not 2-connected, we call the disconnecting vertex a cut vertex. Q: Why the condition on the number of vertices? 20

N-Connectivity A: To avoid being 2-connected. There is also a notion of N-Connectivity where we require at least N vertices to be removed to disconnect the graph. 21

Connectivity in Directed Graphs 1) Weakly connected : can get from a to b in underlying undirected graph 2) Semi-connected (my terminology): can get from a to b OR from b to a in digraph 3) Strongly connected : can get from a to b AND from b to a in the digraph DEF: A graph is strongly (resp. semi, resp. weakly) connected if every pair of vertices is connected in the same sense. 22

Connectivity in Directed Graphs Q: Classify the connectivity of each graph. 23

Connectivity in Directed Graphs A: semi weakstrong 24

Euler and Hamilton Paths -Motivation An pictorial way to motivate the graph theoretic concepts of Eulerian and Hamiltonian paths and circuits is with two puzzles: The pencil drawing problem The taxicab problem 25

Pencil Drawing Problem -Euler Paths Which of the following pictures can be drawn on paper without ever lifting the pencil and without retracing over any segment? 26

Pencil Drawing Problem -Euler Paths Graph Theoretically: Which of the following graphs has an Euler path? 27

Pencil Drawing Problem -Euler Paths Answer: the left but not the right. 28 startfinish

Euler Paths and Circuits Definition DEF: An Euler path in a graph G is a simple path containing every edge in G. An Euler circuit (or Euler cycle) is a cycle which is an Euler path. NOTE: The definition applies both to undirected as well as directed graphs of all types. 29

Taxicab Problem -Hamilton Paths Can a taxicab driver milk his hapless customer by visiting every intersection exactly once, when driving from point A to point B ? 30 A B

Taxicab Problem -Hamilton Paths Graph Theoretically: Is there a Hamilton path from A to B in the following graph? (NO in this case) 31 A B

Hamilton Paths and Circuits Definition DEF: A Hamilton path in a graph G is a path which visits ever vertex in G exactly once. A Hamilton circuit (or Hamilton cycle) is a cycle which visits every vertex exactly once, except for the first vertex, which is also visited at the end of the cycle. NOTE: Again, the definition applies both to undirected as well as directed graphs of all types. 32

Implications to CS Finding Hamilton paths is a very important problem in CS. EG: Visit every city (vertex) in a region using the least trips (edges) as possible. EG: Encode all bit strings of a certain length as economically as possible so that only change one bit at a time. (Gray codes). 33

Implications to CS Analyzing difficulty of Euler vs. Hamilton paths is a great CS case study. Finding Euler paths can be done in O (n) time Finding Hamilton paths is NP-complete! Slight change in definition can result in dramatic algorithmic bifurcation! 34

Finding Euler Paths To find Euler paths, we’ll first give an algorithm for finding Euler cycles and then modify it to give Euler paths. THM: An undirected graph G has an Euler circuit iff it is connected and every vertex has even degree. NOTE: for directed graphs the condition is that G be weakly connected and that every vertex has same in-degree as out-degree. 35

Finding Euler Circuits Q: Why does the following graph have no Euler circuit? 36

Finding Euler Circuits A: It contains a vertex of odd degree. 37

Finding Euler Circuits Let’s prove the theorem constructively. Constructive means that the proof will actually contain an algorithm for constructing the Euler path, when it exists. Part 1) Suppose G is connected and each vertex has even degree. Construct an Euler cycle. We prove this by strong induction on m –the number of edges in G. Base case m = 0: Since G is connected and contains no edges, it must consist of a single vertex. The empty path is an Euler cycle. 1 38

Finding Euler Circuits Induction step for m+1 edges, assuming proved this up to m  0. CLAIM: G contains a simple cycle. Consider an edge e (since m+1 > 0). If e is a self-loop, then is a simple cycle. So can assume that e is a loopless edge: v v’ Since deg(v’ ) > 1 (all degrees are even), another edge e’ must be incident with v’ : 39 v’v’’ e

Finding Euler Circuits So can continue adding edges until we find an edge whose new endpoint has already been encountered during the process. This endpoint is a vertex which is seen twice so at which a simple cycle is based! (This proves claim) 40 Simple cycle

Finding Euler Circuits Gives rise to a recursive proof/algorithm: 1)Find a simple cycle in connected graph with m+1 edges. 2)Delete all the edges from the cycle and find Euler cycles in each resulting component 3)Amalgamate Euler cycles together using the simple cycle obtaining wanted Euler cycle. Let’s see how the amalgamation process works: 41

Finding Euler Circuits Mohammed’s Scimitars 42

Finding Euler Circuits Mohammed’s Scimitars Found a cycle after starting from middle vertex. Delete the cycle: 43

Finding Euler Circuits Mohammed’s Scimitars Found a cycle after starting from middle vertex. Delete the cycle: 44

Finding Euler Circuits Mohammed’s Scimitars Found a cycle after starting from middle vertex. Delete the cycle: 45

Finding Euler Circuits Mohammed’s Scimitars Found a cycle after starting from middle vertex. Delete the cycle: 46

Finding Euler Circuits Mohammed’s Scimitars Found a cycle after starting from middle vertex. Delete the cycle: 47

Finding Euler Circuits Mohammed’s Scimitars Now try again (say from middle vertex): 48

Finding Euler Circuits Mohammed’s Scimitars This time, found a cycle starting and ending at middle vertex: Amalgamate these cycles together from a point of intersection, and delete from graph: 49

Finding Euler Circuits Mohammed’s Scimitars Find another cycle from middle vertex: 50 1

Finding Euler Circuits Mohammed’s Scimitars Find another cycle from middle vertex:

Finding Euler Circuits Mohammed’s Scimitars Find another cycle from middle vertex:

Finding Euler Circuits Mohammed’s Scimitars Find another cycle from middle vertex:

Finding Euler Circuits Mohammed’s Scimitars Find another cycle from middle vertex:

Finding Euler Circuits Mohammed’s Scimitars Find another cycle from middle vertex:

Finding Euler Circuits Mohammed’s Scimitars Find another cycle from middle vertex:

Finding Euler Circuits Mohammed’s Scimitars Find another cycle from middle vertex:

Finding Euler Circuits Mohammed’s Scimitars Find another cycle from middle vertex:

Finding Euler Circuits Mohammed’s Scimitars Find another cycle from middle vertex:

Finding Euler Circuits Mohammed’s Scimitars Find another cycle from middle vertex:

Finding Euler Circuits Mohammed’s Scimitars Amalgamate it to Euler cycle of deleted graph, and delete it. Need to insert cycle between former edges 10 & 11:

Finding Euler Circuits Mohammed’s Scimitars Finally, need to add the triangle. Use same naïve approach looking for cycle in remaining component: ??

Finding Euler Circuits Mohammed’s Scimitars Finally, need to add the triangle. Use same naïve approach looking for cycle in remaining component: ?? 11

Finding Euler Circuits Mohammed’s Scimitars Finally, need to add the triangle. Use same naïve approach looking for cycle in remaining component: ?? 11 12

Finding Euler Circuits Mohammed’s Scimitars Finally, need to add the triangle. Use same naïve approach looking for cycle in remaining component: ??

Finding Euler Circuits Mohammed’s Scimitars Finally, need to add the triangle. Use same naïve approach looking for cycle in remaining component: ??

Finding Euler Circuits Mohammed’s Scimitars Finally, need to add the triangle. Use same naïve approach looking for cycle in remaining component:

Finding Euler Circuits Mohammed’s Scimitars Amalgamate the triangle cycle between edges formerly labeled 9 & 10:

Finding Euler Circuits Mohammed’s Scimitars Amalgamate the triangle cycle between edges formerly labeled 9 & 10: ??

Finding Euler Circuits Mohammed’s Scimitars We found the Euler circuit!

Euler Circuit  All Degrees Even 2 nd half of theorem says that an Euler circuit in a graph implies that all degrees are even: In a simple cycle, whenever path enters vertex, must come out on different edge. Thus every visit of v contributes 2 to deg(v). Thus, if keep only edges which were on the simple cycle, degrees of resulting graph are all even. But in an Eulerian graph G, can find a simple cycle containing all vertices and consequently graph resulting from cycle is G itself!  71

Generalizing to Euler Paths Q: Does the following have an Euler circuit? 72

Generalizing to Euler Paths A: No, vertices of odd degree: Q: But why does it have an Euler path? 73

Generalizing to Euler Paths A: YES! Because exactly 2 vertices of odd degree. So can add a phantom edge between odd degree vertices: 74

Generalizing to Euler Paths All degrees now even so find Euler cycle: 75

Generalizing to Euler Paths Now remove phantom edge obtaining: L

Generalizing to Euler Paths Generalize:

Generalizing to Euler Paths THM: An undirected connected graph has an Euler path iff there are exactly two vertices of odd degree. 78

Blackboard Exercises 1)Prove by induction that Q n always has a Hamilton cycle for n > 1. (This gives a Gray code). 2)Prove that the following graph has no Hamilton cycle: 79