?? girthlenth.m
字號(hào):
%function y=girthlenth(H)
clear ,clc,
load Hdata;
cnodes=length(H(:,1));
bnodes=length(H(1,:));
dv=sum(H(:,1));
dc=sum(H(1,:));
for i=1:bnodes
v_wayback=zeros(dv-1,1); m=1;
for j=1:cnodes
if H(j,i)==1
v_wayback(m,1)=j;
m=m+1;
end
end
k=2; bl=0;
% v_wayback(1,1)所對(duì)應(yīng)的bnodes;
vp=v_wayback;
flag=true;
while(flag)
if k==2
vplen=1;
else
vplen=length(vp);
end
if mod(k,2)==0
vtemp=zeros( vplen*(dc-1),1);
else
vtemp=zeros( vplen*(dv-1),1);
end
vtemplen=length(vtemp);
q=1;
for n=1:vplen
if mod(k,2)==0 % from checknodes to find bitnodes;
if k==2 % the first stage , the prior node is the node i;
vlastnode=i;
else
vlastnode=vlast(floor((n-1)/(dv-1))+1);% pay attention to the denominator;
end
for r=1:bnodes
if H(vp(n),r)==1 & r~=vlastnode % avoid the prior node;
vtemp(q)=r; q=q+1;
end
end
else % from bitnodes to find checknodes;
vlastnode=vlast(floor((n-1)/(dc-1))+1);
for r=1:cnodes
if H(r,vp(n))==1 & r~=vlastnode
vtemp(q)=r;q=q+1;
end
end
end
end
vlast=vp; % keep the prior nodes;
vp=vtemp; % go forward a step;
k=k+1; % keep the stage ;
if mod(k,2)==0
bl=findapath(vtemp,v_wayback); % judge if there exists a path now;
end
if bl==1
girth(i)=k; % find a path and break out of the current inner loop (while);
flag=false;
end
end
end
y=min(girth);
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -