破圈法求解最小支撑树MATLAB代码.docVIP

  • 6
  • 0
  • 约1.05千字
  • 约 2页
  • 2023-06-21 发布于湖北
  • 举报
破圈法: 教材P149 1a) M文件: clc clear all c=[0 2 3 0 0 0 0 0 0 0; 2 0 1 2 0 0 0 0 0 0; 3 1 0 0 2 0 0 0 6 0; 0 2 0 0 1 2 0 0 0 0; 0 0 2 1 0 0 1 0 0 0; 0 0 0 2 0 0 1 3 0 0; 0 0 0 0 1 1 0 0 4 0; 0 0 0 0 0 3 0 0 7 9; 0 0 6 0 0 0 4 7 0 1; 0 0 0 0 0 0 0 9 1 0]; [i,j,k]=find(c); nn=length(i)/2; c2=c; c1=triu(c2); [i,j,k]=find(c1); data=[i;j;k]; D1=data(1:2,:); D2=data(3,:) TM=c2; while nnlength(c)-1 temp1=max(D2); temp2=find(D2==temp1); temp3=temp2(1); TM=c2 TM(D1(1,temp3),D1(2,temp3))=0; TM(D1(2,temp3),D1(1,temp3))=0; TM ff=wallshalt(TM); if ff==1 c2=TM; nn=nn-1; end

文档评论(0)

1亿VIP精品文档

相关文档