Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

**Make sure to present the output within a proper message. For example, assume that you are asked to find the rank of a matrix. Do

image text in transcribed

image text in transcribed

**Make sure to present the output within a proper message. For example, assume that you are asked to find the rank of a matrix. Do not just print the number that represents its rank. You need to show the output in a clear/meaningful statement. Below are some examples for such proper/acceptable formats to show the output: The rank of matrix A = 4 The rank of matrix A equals to 4 rank(A) = 4

*** please follow the instructions and please give me the code in text... The code should be simple and it's so important to be valid for another example ( the code should be in generic form ) not designed to one problem

please solve the whole problem... 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 aij = 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. 0 1 0 0 0 0 direct path from node 1 to node 2 101001 direct path from node 2 to 1:2 to 3: 2 to 6 010100 001011 000 101 01011 o direct path from node 6 to 2: 6 to 4; 6 to 5 4 A= 1 2 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 nodej in the graph. 2 To understand what the theorem says for the example above, let's carefully examine the (6.3) entry of AP 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= 261013 + 262023 +063233 +064243 +265053 +266063 = (0) (0) + (1) (1) + (O)(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 062023 = (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 +23). 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 = A': 1 % Define the adjacency matrix 2 A= 0 1 0 0 0 0; 1010 01: 01010 0; 00101 1: 000101; 01011 0]: 3 4 5 G 8 9 % Compute the powers of A 10 B = A 2 % computes A A 11 C= A3 % computes A A A = B A = A B The obtained B and C matrices are as follows: 1 0 1 0 0 1 0 3 0 2 1 0 1 0 2 0 1 2 B2 = 0 2 0 3 11 0111 2 1 1 0 2 1 1 3 B3 = 0 3 0 2 1 0 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 j. Below are some examples that helps further understanding the interpretation of the power of the adjacency matrix: The (1, 2) entry of B = A is zero, so there are no paths of length two from node 1 to node 2. Verify this by studying the graph. 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: 3+2+1 +2 Path 2: 3232 Path 3 3 4 3 2 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 = A3 is obtained by multiplying the 3rd row of B by the 2nd column of A. This yields the following expression: C32 = 631012 +033032 +636262 = (a32021)212 + (032023 +031043) 32 + (a 36262 +234046)262 (2) = 432021012+ 432223232 +234043032+436462062 +234046062 Path 1 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 031 = 5. 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 j. 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 W1,...,Wg. 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 W1 got 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 "Employee Con- 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 "Employee Contact 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 JD 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

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions

Question

The models used to analyse different national cultures.

Answered: 1 week ago

Question

The nature of the issues associated with expatriate employment.

Answered: 1 week ago