Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(.mat data) Regularly updated traffic infotmation can be used to provide an esta

ID: 2082542 • Letter: #

Question

(.mat data)

Regularly updated traffic infotmation can be used to provide an estaimate of the taken to go from one suburb to another in a city and plan a journey.Use the given .mat file which consist of a cost matrix with the times to go from one suburb to another at a particular instant in time. The cost matrix variable name is M and there are 10 suburbs.Draw the network and find the least cost path from 3 to 9; using Matlab functions.

0 73 0 0 0 0 27 0 72 0 18 0 0 0 0 0 38 55 0 27 4 49 0 14 0 0 0 0 0 8 36 0 0 0 0 0 0 0 23 68 65 0 0 39 0 38 36 36 0 27 0 0 0 48 0 0 0 24 59 2.4 30 0 68 6 26 0 0 46 37 0 3 0 6 0 0 0 0 0 0 63 23 64 0 63 44 11 0 0 0 37 0 0 40 25 32 21 0 0 47 0

Explanation / Answer

%Hi. To solve your problem we have default inbuilt function [dist, path,
%pred]=graphshortestpath(G,S,T)
%For plotting the network we have a function view(biograpgh) and to conver
%normal array to biograph type we just need to use the function
%B=biograph(M)

close all% To close all previously opened Matlab figures and plots
clear all% To clear all stored variables
clc % To clear the command window

M= [0   73   0   0   0   0   27   0   72   0
18   0   0   0   0   0   38   55   0   27
4   49   0   14   0   0   0   0   0   8
36   0   0   0   0   0   0   0   23   68
65   0   0   39   0   38   36   36   0   27
0   0   0   48   0   0   0   24   59   2.4
30   0   68   6   26   0   0   46   37   0
3   0   6   0   0   0   0   0   0   63
23   64   0   63   44   11   0   0   0   37
0   0   40   25   32   21   0   0   47   0]; % Input of the given Matrix

S=sparse(M); % The inbuilt function 'graphshortestpath(M,S,T)' accepts Matrix input in sparse form only. The following function converts the given normal array to sparse array mode
B=biograph(M); % The inbuilt function 'view (Biograph)' accepts Matrix input in sparse form only. The following function converts the given normal array to biograph array mode

view (B) % to plot the network
[dist, path, pred] = graphshortestpath(S,3,9) % where 3 is the starting node and 9 is ending node

%Do not get confused with sparse and biograph. They are just the type of
%variables we declare. It is somewhat similar to how we declare int, char,
%float etc. in C,C++