المملكة العربية السعودية وزارة التعليم العالي جامعة االميرة نورة بنت عبد الرحمن كلية علوم الحاسب والمعلومات Kingdom of Saudi Arabia Ministry of Higher Education Princess Noura bint Abdulrahman University College of Computer & Information Sciences HW-9 Name: ID: Section: QUESTION #1 : Determine whether the graphs shown below have directed or undirected edges, whether they have multiple edges, and whether they have one or more loops. Un Direct edges B b Direct edges multiple edges multiple edges A No loops. more loops QUESTION #2 : For following graph, determine: -The number of vertices and edges. 4 vertices and 8 edges -The in-degree and out-degree of each vertex for the given directed multi-graph. In-degrees: deg -(a) = 2, deg -(b) = 3, deg (c) = 2 deg -(d) = 1. Out-degrees: deg+(a) = 2, deg+(b) = 4, deg+(c) = 1, deg+(d) = 1, - المملكة العربية السعودية وزارة التعليم العالي جامعة االميرة نورة بنت عبد الرحمن كلية علوم الحاسب والمعلومات Kingdom of Saudi Arabia Ministry of Higher Education Princess Noura bint Abdulrahman University College of Computer & Information Sciences The sum of the in-degrees of the vertices and the sum of the outdegrees of the vertices directly. Show that they are both equal to the number of edges in the graph. deg v deg v E vV vV Sum of In-degrees=2+3+2+1= 8 Sum of Out-degrees= 2+4+1+1= 8 Sum of In-degrees= Sum of Out-degrees=8 QUESTION #3 : Determine whether the graphs shown below are bipartite. Justify your answer. 1 1. Yes because : Its vertex set can be partitioned into the two sets V1= { b, e, d} and V2= {a, c} 2. Yes because : Its vertex set can be partitioned into the two sets V1= {a, b, e, d} and V2= {f, c} 2 b المملكة العربية السعودية وزارة التعليم العالي جامعة االميرة نورة بنت عبد الرحمن كلية علوم الحاسب والمعلومات Kingdom of Saudi Arabia Ministry of Higher Education Princess Noura bint Abdulrahman University College of Computer & Information Sciences QUESTION #4 : Construct a precedence graph for the following program: S1 a := 2 S2 b := 1 S6 S3 c := b+1 S4 d := b+ 3 S4 S5 e := a + d S5 S6 f:= d +c + a S3 S1 S2 QUESTION #5: Given the following graph: a. Represent the graph with adjacency list. b. Represent the graph with adjacency matrices. Vertex A B C D adjacency list b,d,c a,d a,d a,b,c المملكة العربية السعودية وزارة التعليم العالي جامعة االميرة نورة بنت عبد الرحمن كلية علوم الحاسب والمعلومات Kingdom of Saudi Arabia Ministry of Higher Education Princess Noura bint Abdulrahman University College of Computer & Information Sciences Adjacent matrices: a b c d a 0 1 1 1 b 1 0 0 1 c 1 0 0 1 d 1 1 1 0 QESTION #6: Draw a graph with the given adjacency matrix. 𝟎 𝟏 𝟎 [𝟏 𝟎 𝟏] 𝟎 𝟏 𝟎 Graph draw: QESTION #7: Does each of these lists of vertices form a path in the following graph? Which are simple? Which are circuits? What are the lengths of those that are paths? i. a,e,b,c,b. ii. e,b,a,d,b,e. iii. c,b,d,a,e,c. المملكة العربية السعودية وزارة التعليم العالي جامعة االميرة نورة بنت عبد الرحمن كلية علوم الحاسب والمعلومات Kingdom of Saudi Arabia Ministry of Higher Education Princess Noura bint Abdulrahman University College of Computer & Information Sciences I. a,e,b,c,b. Is it simple? – No, because it hase the same edge more than one. What is the length? – 3 – Does it have any circuits? no – II. III. – e,b,a,d,b,e. this list of vertices e,b,a,d,b,e. does not form a path in the following graph. IV. c,b,d,a,e,c. Is it simple? – yes What is the length? – 5 – Does it have any circuits? yes – – المملكة العربية السعودية وزارة التعليم العالي جامعة االميرة نورة بنت عبد الرحمن كلية علوم الحاسب والمعلومات Kingdom of Saudi Arabia Ministry of Higher Education Princess Noura bint Abdulrahman University College of Computer & Information Sciences QESTION #8: Determine whether the given graph is connected. 1 yes; it is connected QESTION #9: 2 No , it is connected Determine whether each of these graphs is strongly connected and if not, whether it is weakly connected. 1 2 1, This graph is not strongly connected. Why not? Because there is no .directed path between d and c,c and b, However, it is weakly connected. (Imagine this graph as an undirected ).graph 2, This graph is not strongly connected. Why not? Because there is no .directed path between a and b,b and c, However, it is weakly connected. (Imagine this graph as an undirected graph.)