【正文】
x=A(i,1)::A(j,1)。 y=(xA(i,1))*(A(j,2)A(i,2))/(A(j,1)A(i,1))+A(i,2)。 plot(x,y,39。K39。) end end end hold on location22=[0 18 13 12 11 8 3 1 6 7 10 9 14 16 43 42 49 50 40 34 34]。 for i=1:21 location22(i)=location22(i)+1。 end for i=1:21 aa22(i,1)=A(location22(i),1)。 aa22(i,2)=A(location22(i),2)。 end plot(aa22(:,1),aa22(:,2),39。K*39。) location33=[0 26 31 24 19 25 29 22 30 28 33 46 48 44 41 37 40 47 45]。 for i=1:19 location33(i)=location33(i)+1。 end for i=1:19 aa33(i,1)=A(location33(i),1)。 aa33(i,2)=A(location33(i),2)。 end plot(aa33(:,1),aa33(:,2),39。C*39。) location44=[20 15 4 2 5]。 for i=1:5 location44(i)=location44(i)+1。 end for i=1:5 aa44(i,1)=A(location44(i),1)。 aa44(i,2)=A(location44(i),2)。 end plot(aa44(:,1),aa44(:,2),39。M*39。) %第一階段 for i=1:12 for j=1:12 ww1(i,j)=w(location1(i),location1(j))。 end end l=0。 for i=1:12 dist1(i)=ww1(1,i)。 parent1(i)=location1(i)。 f1(i)=0。 end f1(1)=1。 for i=1:12 cost=inf。 k=1。 for j=2:12 if dist1(j)costamp。amp。f1(j)==0 cost=dist1(j)。 k=j。 end end if k1 f(k)=1。 for t=2:12 if f1(t)==0 if dist1(t)dist1(k)+ww1(k,t) dist1(t)=dist1(k)+ww1(k,t)。 parent1(t)=location1(t)。 l=l+dist1(t)dist1(k)。 end end end end end parent1 l1=l+di(1,parent1(12)) %第二階段 ,共 21個位置 location2=[0 18 13 12 11 8 3 1 6 7 10 9 14 16 43 42 49 50 40 34 34]。 for i=1:21 location2(i)=location2(i)+1。 end for i=1:21 aa2(i,1)=A(location2(i),1)。 aa2(i,2)=A(location2(i),2)。 end for i=1:21 for j=1:21 ww2(i,j)=w(location2(i),location2(j))。 ww2(j,i)=ww2(i,j)。 end end l=0。 for i=1:21 dist2(i)=ww2(1,i)。 parent2(i)=location2(i)。 f2(i)=0。 end f2(1)=1。 for i=1:21 cost=inf。 k=1。 for j=2:21 if dist2(j)costamp。amp。f2(j)==0 cost=dist2(j)。 k=j。 end end if k1 f2(k)=1。 for t=2:21 if f2(t)==0 if dist2(t)dist2(k)+ww2(k,t) dist2(t)=dist2(k)+ww2(k,t)。 parent2(t)=location2(t)。 l=l+dist2(t)dist2(k)。 end end end end end parent2 l2=l+di(1,parent2(21)) %第三 階段 location3=[0 26 31 24 19 25 29 22 30 28 33 46 48 44 41 37 40 47 45]。 for i=1:19 location3(i)=location3(i)+1。 end for i=1:19 aa3(i,1)=A(location3(i),1)。 aa3(i,2)=A(location3(i),2)。 end for i=1:19 for j=1:19 ww3(i,j)=w(location3(i),location3(j))。 ww3(j,i)=ww3(i,j)。 end end l=0。f=0。 for i=1:19 dist3(i)=ww3(1,i)。 parent3(i)=location3(i)。 f3(i)=0。 end f3(1)=1。 for i=1:19 cost=inf。 k=1。 for j=2:19 if dist3(j)costamp。amp。f3(j)==0 cost=dist3(j)。 k=j。 end end if k1 f3(k)=1。 for t=2:19 if f3(t)==0 if dist3(t)dist3(k)+ww3(k,t) dist3(t)=dist3(k)+ww3(k,t)。 parent3(t)=location3(t)。 l=l+dist3(t)dist3(k)。 f=f+1。 end end end end end parent3 l3=l+di(1,parent3(19)) %第四 階段 location4=[20 15 4 2 5]。 for i=1:5 location4(i)=location4(i)+1。 end for i=1:5 aa4(i,1)=A(location4(i),1)。 aa4(i,2)=A(location4(i),2)。 end for i=1:5 for j=1:5 ww4(i,j)=w(location4(i),location4(j))。 ww4(j,i)=ww4(i,j)。 end end l=0。f=0。 for i=1:5 dist4(i)=ww4(1,i)。 parent4(i)=location4(i)。 f4(i)=0。 end f3(1)=1。 for i=1:5 cost=inf。 k=1。 for j=2:5 if dist4(j)costamp。amp。f4(j)==0 cost=dist4(j)。 k=j。 end end if k1 f4(k)=1。 for t=2:5 if f4(t)==0 if dist4(t)dist4(k)+ww4(k,t) dist4(t)=dist4(k)+ww4(k,t)。 parent4(t)=location4(t)。 l=l+dist4(t)dist4(k)。 f=f+1。 end end end end end parent4 l4=l+di(1,parent4(1))+di(1,parent4(5)) l=l1+l2+l3+l4。 ll=l*。 ll2=ll/3600+。 ll ll2