Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Solve this problem using Matlab. Solve this problem using Matlab. Handwriten Solution are not accebtable Thank you. 2 Part 2-Network Application: The Adjacency Matrix of

image text in transcribed

image text in transcribed

Solve this problem using Matlab.

Solve this problem using Matlab.

Handwriten Solution are not accebtable

Thank you.

2 Part 2-Network Application: The Adjacency Matrix of a Graph 2.1 Introduction Definition 1 (Graph). A graph is a finite set of objects called nodes, together with some paths between some of the nodes, as illustrated below. A path of length one is a path that directly connects one node to another. A path of length k is a path made up of k consecutive paths of length one. Definition 2 (Adjacency Matrix). When the nodes have been numbered from 1 ton, the adjacency matrix A of the graph is defined by letting anj = 1 if there is a path of length one between vertices i and j and ajj = 0 otherwise, For example, the graph in Figure 1 has the matrix A shown as its adjacency matrix. 5 A= 01000 07 direct path from node 1 to node 2 101001 direct path from node 2 to 1: 2 to 3: 2 to 6 010100 001011 000101 01011 o direct path from node 6 to 2; 6 to 4; 6 to 5 Figure 1: A graph representation of a network along with its associated adjacency matrix. Theorem 1 (Interpretation of the powers of an adjacency matrix). If A is the adjacency matrix of a graph, then the (ij) entry of Ak is a nonnegative integer which is the number of paths of length k from node i to node ; in the graph. 2 To understand what the theorem says for the example above, let's carefully examine the (6,3) entry of A2 of the graph in Figure 1. The (6.3) entry of A2 is obtained by inner product between the 6th row and the 3rd column of A. That is, (6,3) entry of A = 461913+ (62023 +063233 +264043 +065053 +266063 = (0) (0) + (1)(1) + (0) 0) + (1)(1) + (1)(0) + (0) (0) = 2. (1) Explain what each term in the sum above tells about paths of length 2 from node 6 to node 3. It is clear that there are two paths of length two that link node 6 to node 3 (i.e., the first path is 6 - 2 - 3 and the second path is 6 - 4 - 3), which is equal to (6.3) entry of A?. In particular, there are two terms in the expression in (1) that contribute to obtain the value 2. These two terms are 062023 = and 264043 =. Each one of these two terms represents one path. For example, by 462023 = (1)(1) = 1; this says that the length one paths 6 + 2 and 2 + 3 appear in the graph, and together they give one path from node 6 to node 3, of length 2 (i.e., 6 + 2 + 3). Similarly, 064043 = (1)(1) = 1; this says that the length one paths 6 + 4 and 4 + 3 appear in the graph, and together they give one path from node 6 to node 3, of length 2 (i.e. 6 +4+3). Te following Matlab code define the adjacency matrix A of Figure 1 and computes B = A and C = A3: 3 1 % Define the adjacency matrix 2 A = 0 1 0 0 0 0; 101001; 01010 0; 00101 1; 00010 1: 01011 0]: 1 5 6 7 9 % Compute the powers of A 10 B = A 2 % computes A A 11 C = A 3 % computes A A A = B.A = A*B The obtained B and C matrices are as follows: B2 = 101001 0 3 0 2 1 0 1 0 2 0 1 2 0 2 0 31 1 0 1 1 1 2 1 1 0 2 1 1 3 B3 = 0 3 0 2 10 3 0 5 1 2 6 0 5 0 5 2 1 2 1 5 2 4 6 1 2 2 4 2 4 0 6 1 6 4 2 It is worth to reemphasize that each non-zero term in the expression that calculates the (ij) entry in A is corresponding to one path of length k that connects node i to node ;. Below are some examples that helps further understanding the interpretation of the power of the adjacency matrix: The (1,2) entry of B = A2 is zero, so there are no paths of length two from node 1 to node 2. Verify this by studying the graph. 3 The (3, 2) entry of C = A is 5, so there are 5 paths of length 3 from node 3 to node 2. These five paths are: Path 1: 32+1 +2 Path 2: 3232 Path 3: 3 +4 +32 Path 4: 3 + 2 6 + 2 Path 5: 3+ 4+ 6 2 To illustrate how we obtain these 5 paths. Again, the (3, 2) entry of C = A is obtained by multiplying the 3rd row of B by the 2nd column of A. This yields the following expression: C32 = 631012 + b330 32 + b36462 = (232021412 + (432423 +23443)a32 + (a36062 +234446)462 (2) = 432421212 +232023032 + 434043032 +236462062 +434046062 Path 2 Path 3 Path 4 Path 5 What are the paths of length two from node 2 to itself? This is equivalent to the (2, 2) entry of B. That is by2 = 3. What are the paths of length three from node 3 to node 4? This is equivalent to the (3, 4) entry of C. That is C34 = 5. Path 1 Definition 3 (Contact level). When we have a graph, we will say that there is a contact level k between node i and node ; if there is a path of length less than or equal to k from node i to node 3. Suppose A is the adjacency matrix of a graph. To decide which nodes have contact level k with each other requires calculating the sum A+ A+ ... + Ak. 2.2 Task Exercise 1. In a manufacturer, there are 8 workers, denoted by Wi....,W8. It is known that if an worker becomes infected with COVID-19, he/she could spread this through contact with workers up to k contact levels. In particular, let us assume that the infection can spread up to 2 levels. That is, if Wigot infected and he/she is in direct contact with W2. Then, all workers who are in direct contact with W, are in high risk to be infected. Consider the following graph in Figure 2 that shows the level one contacts between the workers. Write a matlab code that is composed of the "main" script and one function called "EmployeeCon- tact Level" as described below: (a) Main script: 4 Defines the adjacency matrix A. Asks the user to enter the required contact level (i.e., k). call the function "EmployeeContact Level" Print the returned output from the function "Employee Contact Level" in a proper format. (b) Employee Contact Level function Input: Adjacency matrix (i.e., A). Infection spread contact level (i.e., k). Output: The number and indices of the workers who have a contact level k with each worker. The index of the most dangerous worker (i.e., the one who will spread the disease among others if he/she got infected more than any other employee) W5 W4 W20 W3 W8 W7 W6 W1 Figure 2: A graph representation of level one contacts between the 8 workers

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions

Question

7. Understand the challenges of multilingualism.

Answered: 1 week ago