Math.3336: Discrete Mathematics Chapter 10 Graph Theory Instructor: Dr. Blerina Xhabli Department of Mathematics, University of Houston https://www.math.uh.edu/ blerina Email: blerina@math.uh.edu Fall 2018 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 1/38
Assignments to work on Homework #9 due Friday, 11/30, 11:59pm No credit unless turned in by 11:59pm on due date Late submissions not allowed, but lowest homework score dropped when calculating grades Homework will be submitted online in your CASA accounts. You can find the instructions on how to upload your homework in our class webpage. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 2/38
Chapter 10 Graphs Chapter 10 Overview Graphs and Graph Models Section 10.1 Graph Terminology/Special Types of Graphs Section 10.2 Representing Graphs and Graph Isomorphism Section 10.3 Connectivity Section 10.4 Euler and Hamiltonian Graphs Section 10.5 Shortest-Path Problems Section 10.6 Planar Graphs Section 10.7 Graph Coloring Section 10.8 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 3/38
Graphs and Graph Models Graph is a fundamental mathematical structure in computer science Graph G = (V, E) consists of a set of vertices (nodes) V and edges E between these nodes Lots of applications in many areas: web search, transportation, biological models,... Will encounter graphs and graph algorithms in many different courses of Computer Science Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 4/38
Example: Social Network as a Graph Nodes represent users (Michael, Jessica, Stuart... ) Edges represent friendship (e.g., Michael is friends with Jessica) Edge between nodes u and v is written as (u, v) e.g., (Sarah, Andrew) is an edge in this graph. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 5/38
Terminology Two nodes u and v are adjacent if there exists an edge between them (e.g., nodes 1 and 3) An edge (u, v) is incident with nodes u and v Degree of a vertex v, written deg(v), is the number of edges incident with it. The loop at a vertex contributes twice to the degree of that vertex. Neighborhood of a vertex v, denoted by N (v), is the set of vertices adjacent to it. If A V, then N (A) = v A N (v) Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 6/38
Question Consider a graph G with vertices a, b, c, d and edges (a, b), (b, c), (a, c), (c, d), (b, d). 1 Draw this graph. 2 What is the degree of each vertex? deg(a) = deg(d) = 2, deg(b) = deg(c) = 3 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 7/38
Simple Graphs Graph contains a loop if any node is adjacent to itself A simple graph does not contain loops and there exists at most one edge between any pair of vertices Graphs that have multiple edges connecting two vertices are called multi-graphs A pseudograph may include loops, as well as multiple edges connecting the same pair of vertices. Most graphs we will look at are simple graphs Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 8/38
Graph Models: Computer Networks To model a computer network where we are only concerned whether two data centers are connected by a communications link, we use a simple graph. To model a computer network where we care about the number of links between data centers, we use a multigraph. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 9/38
Graph Models: Computer Networks(continued) To model a computer network with diagnostic links at data centers, we use a pseudograph, as loops are needed. To model a network with multiple one-way links, we use a directed multigraph. Note that we could use a directed graph without multiple edges if we only care whether there is at least one link from a data center to another data center. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 10/38
Handshaking Theorem Let G = (V, E) be a graph with m edges. Then: deg(v) = 2m v V Intuition: Each edge contributes two to the sum of the degrees Proof: By induction on the number of edges. Base case: If m = 0, then sum of degrees is 0. Induction: (Sketch) Remove one arbitrary edge from G, now inductive hypothesis applies. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 11/38
Applications of Handshaking Theorem Is it possible to construct a graph with 5 vertices where each vertex has degree 3? No, because the sum of degrees must be an even number. Every graph has an even number of vertices of odd degree. If n people go to a party and everyone shakes everyone else s hand, how many handshakes occur? 2m = v V deg(v) = n(n 1) m = n(n 1)/2 because people are vertices, and edges is the number of handshakes. Each vertex has degree n-1. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 12/38
Directed Graphs All graphs we considered so far are undirected In undirected graphs, edge (u, v) same as (v, u) But sometimes necessary to assign directions to edges (e.g., links from one webpage to another) A directed edge (arc) is an ordered pair (u, v) (i.e., (u, v) not same as (v, u)) A directed graph is a graph with directed edges Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 13/38
In-Degree and Out-Degree of Directed Graphs The in-degree of a vertex v, written deg (v), is the number of edges going into v deg (a) = 1 The out-degree of a vertex v, written deg + (v), is the number of edges leaving v deg + (a) = 2 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 14/38
Handshaking Theorem for Directed Graphs Let G = (V, E) be a directed graph. Then: deg (v) = deg + (v) = E v V v V v V deg (v) = 5 v V deg+ (v) = 5 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 15/38
Subgraphs A graph G = (V, E) is a subgraph of another graph G = (V, E ) if V V and E E Example: Every graph is a subgraph of itself. Graph G is a proper subgraph of G if G G. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 16/38
Question Consider a graph G with vertices {(v 1, v 2, v 3, v 4 )} and edges (v 1, v 3 ), (v 1, v 4 ), (v 2, v 3 ). Which of the following are subgraphs of G? 1 Graph G 1 with vertex v 1 and edge (v 1, v 3 ) 2 Graph G 2 with vertices {v 1, v 3 } and edge (v 1, v 3 ) 3 Graph G 3 with vertices {v 1, v 3 } and no edges 4 Graph G 4 with vertices {v 1, v 2 } and edge (v 1, v 2 ) Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 17/38
Induced Subgraph Consider a graph G = (V, E) and a set of vertices V such that V V Graph G is the induced subgraph of G with respect to V if: 1 G contains exactly those vertices in V 2 For all u, v V, edge (u, v) G iff (u, v) G Subgraph induced by vertices {C, D}: Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 18/38
Complete Graphs A complete graph on n vertices K n is a simple undirected graph in which every pair of vertices is connected by one edge. How many edges does a complete graph with n vertices have? n(n 1)/2 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 19/38
Cycle Graphs A cycle graph C n, n 3 consists of n vertices v 1, v 2,..., v n and edges (v 1, v 2 ), (v 2, v 3 ),..., (v n 1, v n ), (v n, v 1 ). How many edges does a cycle graph with n vertices have? n Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 20/38
Wheel Graphs A wheel graph W n, n 3 is obtained when an additional vertex is added to the cycle C n and connected to all the vertices of C n by new edges. How many edges does a wheel graph with n vertices have? 2n Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 21/38
Bipartite graphs A simple undirected graph G = (V, E) is called bipartite if V can be partitioned into two disjoint sets V 1 and V 2 such that every edge in E connects a V 1 vertex to a V 2 vertex C V1 V2 A B E D A C E B D Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 22/38
Example I Bipartite and Non-Bi-partite Graphs Is this graph bipartite? no A B C What about this graph? yes A C E B D F Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 23/38
Example II Bipartite and Non-Bi-partite Graphs Which of these graphs is bipartite? G Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 24/38
Bipartite Graphs and Graph Colouring A simple graph is bipartite if and only if it is possible to assign one of two different colors to each vertex of the graph so that no two adjacent vertices are assigned the same color. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 25/38
Graph Coloring A coloring of a graph is the assignment of a color to each vertex so that no two adjacent vertices are assigned the same color. A graph is k-colorable if it is possible to color it using k colors. e.g., graph on left is 3-colorable Is it also 2-colorable? No. Look at blue vertex. You would need to give its neighbors different colors, but you cannot because there are edges between them. The chromatic number of a graph is the least number of colors needed to color it. What is the chromatic number of this graph? 3 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 26/38
Question Consider a graph G with vertices {v 1, v 2, v 3, v 4 } and edges (v 1, v 2 ), (v 1, v 3 ), (v 2, v 3 ), (v 2, v 4 ). Which of the following are valid colorings for G? 1 v 1 = red, v 2 = green, v 3 = blue not valid 2 v 1 = red, v 2 = green, v 3 = blue, v 4 = red valid 3 v 1 = red, v 2 = green, v 3 = red, v 4 = blue not valid Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 27/38
Examples What are the chromatic numbers for these graphs? A B A B A B C D C D C D Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 28/38
Applications of Graph Coloring Graph coloring has lots of applications, particularly in scheduling. Example: What s the minimum number of time slots needed so that no student is enrolled in conflicting classes? 311 312 314 331 429 439 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 29/38
Bipartite Graphs and Colorability Prove that a graph G = (V, E) is bipartite if and only if it is 2-colorable. Proof. Assume bipartite. Then, we can partition V into two disjoint sets V 1 and V 2 such that every edge connects a V 1 to a V 2 vertex. Assign V 1 vertices color red, and V 2 vertices color blue. This is a valid coloring... other direction similar. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 30/38
Complete graphs and Colorability Prove that any complete graph K n has chromatic number n. Proof. Proof is by contradiction: Suppose it s n 1 colorable. This would imply there exists two vertices with the same color. But in K n any pair of vertices is connected, hence this cannot be a valid coloring. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 31/38
Complete Bipartite Graphs A complete bipartite graph K m,n is a graph that has its vertex set partitioned into two subsets V 1 of size m and V 2 of size n such that there is an edge from every vertex in V 1 to every vertex in V 2. How many edges does a complete graph K m,n have? mn Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 32/38
Representing Graphs and Graph Isomorphisms An adjacency list can be used to represent a graph with no multiple edges by specifying the vertices that are adjacent to each vertex of graph. Suppose a graph G = (V, E) is a simple graph with n vertices, say v 1, v 2,..., v n. The adjacency matrix A G of G with respect to the listing of vertices is the n n zero-one matrix with 1 as its (i, j )th entry when v i and v j are adjacent, and 0 elsewhere. Let G = (V, E) be an undirected graph with vertices v 1, v 2,..., v n, and edges e 1, e 2,..., e m. The incidence matrix with respect to the ordering of V and E is the n m matrix M = [m ij ], where m ij = 1 when edge e j is incident with v i, and 0 elsewhere. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 33/38
Graph Isomorphisms The simple graphs G 1 = (V 1, E 1 ) and G 2 = (V 2, E 2 ) are isomorphic if there is a one-to-one and onto function f from V 1 to V 2 with the property that a and b are adjacent in G 1 if and only if f (a) and f (b) are adjacent in G 2, a, b V 1 Such a function is called isomorphism. Two simple gaphs that are not isomorphic are called nonisomorphic. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 34/38
Example I Show that the graphs G = (V, E) and H = (W, F ) are isomorphic. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 35/38
Example II Show that the graphs G = (V, E) and H = (W, F ) are not isomorphic. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 36/38
Example III Determine whether the graphs G = (V, E) and H = (W, F ) are isomorphic. Non-Isomorphic Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 37/38
Example IV Determine whether the graphs G = (V, E) and H = (W, F ) are isomorphic. Isomorphic Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Chapter 10 Graph Theory 38/38