求下面函数的解释,看不懂function A = fun(W)[m,n] = size(W); e = 0;for i = 1 :mfor j = i :nif W(i,j) = 0e = e + 1;E(e,:) = [i,j,W(i,j)];endendend% 按权值大小排列边的顺序for i = 1 :e - 1for j = i + 1 :eif E(i,3) > E(j,3)temp = E(j,

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 18:47:08

求下面函数的解释,看不懂function A = fun(W)[m,n] = size(W); e = 0;for i = 1 :mfor j = i :nif W(i,j) = 0e = e + 1;E(e,:) = [i,j,W(i,j)];endendend% 按权值大小排列边的顺序for i = 1 :e - 1for j = i + 1 :eif E(i,3) > E(j,3)temp = E(j,
求下面函数的解释,看不懂
function A = fun(W)
[m,n] = size(W);
e = 0;
for i = 1 :m
for j = i :n
if W(i,j) = 0
e = e + 1;
E(e,:) = [i,j,W(i,j)];
end
end
end
% 按权值大小排列边的顺序
for i = 1 :e - 1
for j = i + 1 :e
if E(i,3) > E(j,3)
temp = E(j,:);
E(j,:) = E(i,:);
E(i,:) = temp;
end
end
end
A = zeros(1,3);
S = 1 :n;
for i = 1 :e
% if find-set(u) = find-set(v)
if S(E(i,1)) = S(E(i,2))
% A = A + (u,v)
A = cat(1,A,E(i,:));
%union(u,v)
indicator = S(E(i,1));
for j = 1 :n
if S(j) == indicator
S(j) = S(E(i,2));
end
end
end
end
A(1,:) = [];
MATLAB求解求不出来。

求下面函数的解释,看不懂function A = fun(W)[m,n] = size(W); e = 0;for i = 1 :mfor j = i :nif W(i,j) = 0e = e + 1;E(e,:) = [i,j,W(i,j)];endendend% 按权值大小排列边的顺序for i = 1 :e - 1for j = i + 1 :eif E(i,3) > E(j,3)temp = E(j,
这是一个以算法、权值平均数为基础的复合函数,很多的赋值语句是计算机选修中VB的专用语句,解答出来非常麻烦,所以推荐你看一下这两本书(高一数学必修3,第一章,算法初步)与(算法与程序设计,VB选修).这两本书都是高一学的.
希望对您有帮助

bb