Radius=10;
D=[];%度数
Node_Num=120;
pointer=[];%flag为1的点的集合
flag=zeros(1,Node_Num);%标记已经选过的数
A=zeros(Node_Num,Node_Num);%构造邻接矩阵
x=[57,95,34,31,52,30,15,75,75,65,55,41,36,72,16,85,86,75,32,5,16,25,72,68,61,37,48,81,23,35,6,85,64,22,69,80,76,88,25,62,70,45,35,75,35,56,27,92,25,44,5,17,90,25,58,95,87,68,30,9,32,47,50,56,56,47,80,10,12,63,39,81,43,17,80,45,92,78,89,51,40,65,76,30,26,28,25,29,40,4,74,41,39,95,72,79,78,10,8,15,45,70,90,84,20,40,55,5,73,22,17,50,55,87,72,55,7,85,35,10];
y=[58,74,12,68,67,4,75,52,30,28,63,61,20,24,10,49,90,90,20,92,35,66,4,33,35,78,46,31,90,66,33,9,37,13,43,83,13,94,95,45,70,42,9,41,91,30,92,90,58,52,80,33,5,74,47,2,72,88,28,9,95,71,43,43,25,25,64,96,33,70,9,89,14,25,55,61,40,22,45,51,90,49,7,98,34,99,8,63,83,11,44,25,21,51,76,8,44,80,89,95,90,82,78,78,70,71,70,95,18,28,80,10,20,22,98,79,2,20,50,68];
plot(x,y,'k+');
for i=1:Node_Num
num=0;
for j=1:Node_Num
if i~=j
if [x(i)-x(j)]^2+[y(i)-y(j)]^2<=Radius^2
line([x(i),x(j)],[y(i),y(j)]);
num=num+1;
fprintf('(%d,%d)',i,j);
A(i,j)=1;
end
end
end
d(i)=num;
D=[D,d(i)];%计算度数
end
disp(D);
disp(A);
for ss=1:Node_Num
if flag(ss)==0
max=D(ss);
j=ss;
for i=1:Node_Num
if max
max=D(i);
j=i;%依次找度数最大的顶点
end
end
flag(j)=1;
for k=1:Node_Num
if A(j,k)==1
flag(k)=2;%相临的节点标记为2
end
end
end
end
D37