CODE:
while 1
outnneighbors = zeros(1,n);
innneighbors = zeros(1,n);
G = directG(n,dist,thresh);
Graph.P = pos;
outcount = 0;
incount = 0;
for i=1:n
outneighbors{i} = find(G.A(i,:));%find function - return the all nonzero elements of array (G(i,:)),row
% 即,返回数列的非零值坐在的列数,G中有几个非零数即表示有几个邻居节点,因为G为
% 图的邻接矩阵,如果相邻节点之间存在edge,则取值为1
outnneighbors(i) = numel(outneighbors{i});%numel function-return the number of elements,n, in array(neighbors{i})
outcount = outcount +1;
if outnneighbors (i) ==0
break;
else
inneighbors{i} = find(G.A(:,i));%find function - return the all nonzero elements of array (G(i,:)),row
% 即,返回数列的非零值坐在的列数,G中有几个非零数即表示有几个邻居节点,因为G为
% 图的邻接矩阵,如果相邻节点之间存在edge,则取值为1
innneighbors(i) = numel(inneighbors{i});%numel function-return the number of elements,n, in array(neighbors{i})
incount = incount +1;
if innneighbors (i) ==0
break;
end
if incount >= n
break;
end
end
if outcount >= n
break;
end
break;
end
end