CS311H: Discrete Mathematics Introduction to Graph Theory Announcements Directed Graphs In-Degree and Out-Degree of Directed
Total Page:16
File Type:pdf, Size:1020Kb
Announcements CS311H: Discrete Mathematics Introduction to Graph Theory I Homeworkdue now! I Next HW out, due next Tuesday Instructor: I¸sıl Dillig I Midterm 2 next Thursday!! Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 1/34 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 2/34 Directed Graphs In-Degree and Out-Degree of Directed Graphs I All graphs we considered so far are undirected I In undirected graphs, edge (u, v) same as (v, u) I The in-degree of a vertex v, written deg−(v), is the number I A directed edge (arc) is an ordered pair (u, v) of edges going into v (i.e., (u, v) not same as (v, u)) I deg−(a) = I A directed graph is a graph with directed edges + I The out-degree of a vertex v, written deg (v), is the number of edges leaving v + I deg (a) = Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 3/34 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 4/34 Handshaking Theorem for Directed Graphs Subgraphs Let G = (V , E) be a directed graph. Then: I A graph G = (V , E) is a subgraph of another graph + deg−(v) = deg (v) = E G0 = (V 0, E 0) if V V 0 and E E 0 | | ⊆ ⊆ v V v V X∈ X∈ I Example: I v V deg−(v) = ∈ P + I v V deg (v) = ∈ P I Graph G is a proper subgraph of G if G = G . 0 6 0 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 5/34 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 6/34 1 Question Induced Subgraph I Consider a graph G = (V , E) and a set of vertices V 0 such that V V Consider a graph G with vertices v , v , v , v and edges 0 ⊆ { 1 2 3 4} (v , v ), (v , v ), (v , v ). 1 3 1 4 2 3 I Graph G0 is the induced subgraph of G with respect to V 0 if: Which of the following are subgraphs of G? 1. G0 contains exactly those vertices in V 0 2. For all u, v V 0, edge (u, v) G0 iff (u, v) G 1. Graph G1 with vertex v1 and edge (v1, v3) ∈ ∈ ∈ 2. Graph G with vertices v , v and no edges I Subgraph induced by vertices C , D : 2 { 1 3} { } 3. Graph G with vertices v , v and edge (v , v ) 3 { 1 2} 1 2 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 7/34 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 8/34 Complete Graphs Bipartite graphs I A simple undirected graph G = (V , E) is called bipartite if V I A complete graph is a simple undirected graph in which every can be partitioned into two disjoint sets V1 and V2 such that pair of vertices is connected by one edge. every edge in E connects a V1 vertex to a V2 vertex C A D EB I How many edges does a complete graph with n vertices have? Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 9/34 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 10/34 Examples Bipartite and Non-Bi-partite Graphs Questions about Bipartite Graphs I Is this graph bipartite? A I Does there exist a complete graph that is also bipartite? B C I What about this graph? A E I Consider a graph G with 5 nodes and 7 edges. Can G be C bipartite? D B F Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 11/34 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 12/34 2 Graph Coloring Question I A coloring of a graph is the assignment of a color to each vertex so that no two adjacent Consider a graph G with vertices v1, v2, v3, v4 and edges vertices are assigned the same color. { } (v1, v2), (v1, v3), (v2, v3), (v2, v4). I A graph is k-colorable if it is possible to color it using k colors. Which of the following are valid colorings for G? I e.g., graph on left is 3-colorable 1. v1 = red, v2 = green, v3 = blue I Is it also 2-colorable? 2. v1 = red, v2= green, v3 = blue, v4 = red I The chromatic number of a graph is the least number of 3. v1 = red, v2= green, v3 = red, v4 = blue colors needed to color it. I What is the chromatic number of this graph? Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 13/34 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 14/34 Examples Applications of Graph Coloring I Graph coloring has lots of applications, particularly in scheduling. What are the chromatic numbers for these graphs? A B A B A B I Example: What’s the minimum number of time slots needed so that no student is enrolled in conflicting classes? C D C D C D 311 314 312 331 429 439 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 15/34 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 16/34 Bipartite Graphs and Colorability Complete graphs and Colorability Prove that a graph G = (V , E) is bipartite if and only if it is Prove that any complete graph Kn has chromatic number n. 2-colorable. Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 17/34 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 18/34 3 Degree and Colorability Degree and Colorability, cont. Theorem: Every simple graph G is always max degree(G) + 1 colorable. I Remove v and all its incident edges from G; call this G0. I Proof is by induction on the number of vertices n. I By the IH, G0 is max degree(G0) + 1 colorable. I Let P(n) be the predicate “A simple graph G with n vertices I Let C 0 be the coloring of G0: Suppose C 0 assigns colors is max-degree(G)-colorable” c ,..., c to v’s n neighbors. Clearly, p n. 1 p ≤ I Base case: n = 1. If graph has only one node, then it cannot I Now, create coloring C for G: have any edges. Hence, it is 1-colorable. I C (v 0) = C 0(v 0) for any v = v 0 6 I Induction: Consider a graph G = (V , E) with k + 1 vertices. I C (v) = cp+1 I Now consider arbitrary v V with neighnors v ,..., v ∈ 1 n Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 19/34 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 20/34 Degree and Colorability, cont. Star Graphs and Colorability I Two possibilities: (i) cp+1 was used in C 0, or (ii) new color I Case 1: Then, G is max degree(G0) + 1 colorable, and I A star graph Sn is a graph with one therefore max degree(G) + 1 colorable. vertex u at the center and the only edges are from u to each of v1,..., vn 1. − I Case 2: Coloring C uses p + 1 colors. I Draw S4. I We know p n, where n is num neighbors ≤ I What is the chromatic number of Sn ? I What can we say about max degree(G)? I Thus, p + 1 max degree(G) + 1 ≤ Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 21/34 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 22/34 Question About Star Graphs Connectivity in Graphs a Suppose we have two star graphs Sk and Sm . Now, pick a random vertex from each graph and connect them with an edge. b I Typical question: Is it possible to get from some node u to another node v? Which of the following statements must be true about the x resulting graph G? w I Example: Train network – if there is path from u to v, possible to take train from u to u 1. The chromatic number of G is 3 y v and vice versa. v 2. G is 2-colorable. d I If it’s possible to get from u to v, we say u and v are connected and there is a path between u and v 3. max degree(G) = max(k, m). c Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 23/34 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 24/34 4 Paths Example I A path between u and v is a sequence of edges that starts at vertex u, moves along adjacent edges, and ends in v. I Consider a graph with vertices x, y, z, w and edges { } (x, y), (x, w), (x, z), (y, z) I Example: u, x, y, w is a path, but u, y, v and u, a, x are not I What are all the simple paths from z to w? I Length of a path is the number of edges I What are all the simple paths from x to y? traversed, e.g., length of u, x, y, w is 3 I How many paths (can be non-simple) are there from x to y? I A simple path is a path that does not repeat any edges I u, x, y, w is a simple path but u, x, u is not Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 25/34 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Introduction to Graph Theory 26/34 Connectedness Example I Prove: Suppose graph G has exactly two vertices of odd I A graph is connected if there is a path degree, say u and v.