91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

復(fù)雜網(wǎng)絡(luò)最短路徑代碼,可以學(xué)習(xí),可以直接用。能很好的計(jì)算出網(wǎng)絡(luò)的最短路徑。

資源截圖

代碼片段和文件信息

clc;
clear?all;
n=input(‘enter?the?number?of?nodes‘);
conn=input(‘enter?the?connected?nodes‘);
delarr=ones(n);
delarr=10000*delarr;
len=length(conn);
delay2=randint(1(len/2)[10?50]);
k=1;
for?i=1:2:len;
????delarr(conn(i)conn(i+1))=delay2(k);
????delarr(conn(i+1)conn(i))=delay2(k);
????k=k+1;
end
for?i=1:n
????delarr(ii)=0;
end
disp(‘....Delay?time.....‘);
disp(delarr);
gr=delarr;
v=[1:n];
p=perms(v);
start=input(‘enter?the?source?node‘);
dest=input(‘enter?the?destination?node‘);
%finding?all?possible?paths?and?thier?delays
paths=zeros(factorial(n-1)n);
index=0;
for?i=1:factorial(n);
????if?p(i1)~=start;
????????continue;
????end
????de=0;
????temp=p(i1);
????index=index+1;
????paths(index1)=temp;
????for?j=2:n;
????????if(gr(tempp(ij))>0?&&?gr(tempp(ij))<1000);
????????????flag=1;
????????????de=de+gr(tempp(ij));
????????????temp=p(ij);
????????????paths(indexj)=temp;
????????????if?temp?==?dest
????????????????delay?(index)=de;
????????????????break;
????????????end
????????else
????????????flag=0;
????????????index=index-1;
????????????break;
????????end;
????end;
end;
%removing?the?repeated?paths
j=1;
delay1(j)=?delay(1);
paths1(j:)?=?paths(1:);
for?i=2:length(delay);
????if?delay(i-1)~=delay(i);
????????j=j+1;
????????delay1(j)=delay(i);
????????paths1(j:)=paths(i:);
????end;
end;
shortind=i;
%displaying?all?paths?and?also?the?delay
for?i=1:length(delay1);
????for?j=1:n;
????????if?paths1(1j)~=0;
????????????fprintf(‘%d->‘paths1(ij));
????????else
????????????break;
????????end;
????end;
????fprintf(‘\b\b:delay=%d\n‘delay1(i));
end;
%shortest?path?and?its?delay
disp(‘‘);
disp(‘the?shortest?path?is‘);
for?j=1:n;
????if?paths1(shortindj)~=0;
????????fprintf(‘%d->‘paths1(shortindj));
????else
????????break;
????end;
end;
fprintf(‘\b\b\t\t?delay=%d\n‘delay1(shortind));





?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----

?????文件???????1924??2009-10-17?12:14??shortest.m

-----------?---------??----------?-----??----

?????????????????1924????????????????????1


評(píng)論

共有 條評(píng)論

相關(guān)資源