Question: In Matlab use Dijkstras algorithm and draw the routing graphs for each iteration by indicating the extended source and weight for each nodes. Code: %routing

In Matlab use Dijkstras algorithm and draw the routing graphs for each iteration by indicating the extended source and weight for each nodes. Code: %routing algorithm clear all; close all; N=7; rand("seed",123456); x=randi([10, 90],1,N); y=randi([10, 90],1,N); x(1)=0;y(1)=0; x(N)=100; y(N)=100; figure plot(x(2:N-1),y(2:N-1),"o","markersize",15,"markerfacecolor","k"); hold on; plot([x(1) x(N)],[y(1) y(N)],"s","markersize",15,"markerfacecolor","b"); grid on; for i=1:N text(x(i),y(i)+5,strcat("N",num2str(i))); endsource=[1]; dest=[2:N]; w=ones(1,N)*inf; w(1)=0; d=[]; for i=1:length(dest) j=dest(i); for k=1:length(source) l=source(k); dd=sqrt((x(j)-x(l))^2+(y(j)-y(l))^2); if dd>601 dd=inf; end d(i,k)=dd+w(l); end end dim=size(d); if dim(2)~=1 d=min(d'); end [md,idx]=min(d); j=dest(idx); plot(x(j),y(j),"rs","markersize",20,"linewidth",1.5); text(x(j),y(j)-5,num2str(md)); source=[source j]; dest(idx)=[]; w(j)=md; pause(1);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!