📄 con_2_range.m
字号:
%**************************************************************************
%** File name : con_2_range.m
%** Author : Liufengwei (English name:andy)
%** Creation date : 4,24,2007,Tuesday
%** Modified date:
%** Parameter explanation : See the note in the program
%**************************************************************************
% ** This simulation is done to investigate the 2-connectivity probability
% analyzed in paper<On the minimum node degree and connectivity of a wireless multihop network>
% ** Model: Distribute n=500 nodes in 1000*1000m^2 accoring to uniform distribution;
% there is an edge between nodes if their distance is less than r0;
% ** Goal: simulate the formula in paper<On the minimum node degree and connectivity of a wireless multihop network>
% ** Explanation : We delete nodes one after another and check the network after deleting the node
% is connected.If so, then the network is 2-connectivity
%** Program process:
%************************************************************************
%function
%***********first initialize simulaiton parameters***************
tic
run_times = 500 ; % simulation times
Nodenum = 50 ; % number of nodes
square_edge = 100 ; % the square edge length
N0 = [2 ] ; % minimum degree
Len_N0 = length(N0) ; % length of N0
Radio_down = 2 ; % the minimum of radio range
Radio_step = 2 ; % increment step
Radio_up = 46 ; % the maximum of radio range
Radio = [Radio_down: Radio_step: Radio_up]; % radio range
Len = length(Radio) ; % number of radio range
%*****************first initialize simulaiton matrix ***********************
NodesXY = zeros(Nodenum, 2) ;% store the location of nodes
del_NodesXY = zeros((Nodenum-1), 2) ;% store the location of nodes after deleting one node
simu_Pdmin = zeros(Len_N0, Len); % the probability of minimun network degree greater than N0
ana_Pdmin = zeros(Len_N0, Len);
for run =1 : run_times
run
% rand('state', sum(100*clock))
NodesXY = square_edge*(rand(Nodenum, 2)) ; % generate coordinates of node
index =1 ;
for radio = Radio_down:Radio_step:Radio_up
for n = 1:Nodenum
return_value = 0 ;
if n==1
del_NodesXY = NodesXY(2:Nodenum, :) ;
else
del_NodesXY = [NodesXY(1:(n-1), :) ; NodesXY((n+1): Nodenum, :) ];
end
return_value = is_connected_boolean(del_NodesXY, radio,square_edge) ;
if return_value==0 % if there is one cutvertice,then there network is not 2-connectivity
break
end
end % end for n
simu_Pdmin(index) = simu_Pdmin(index) + return_value ;
index = index+1
end % end for radio
end % end for run
simu_Pdmin = simu_Pdmin/run_times ; %calculate the prob of degree of every node greater than N0
% Pdmin_N=prod(G_than_N0);
%**********Calculate the analytical prob********************
A = square_edge^2 ; % the area of system plane
for i = 1: Len_N0
j = 1;
for radio = Radio_down: Radio_step: Radio_up
for N=0 : N0(i)-1
ana_Pdmin(i,j)=((Nodenum/A)*pi*radio^2)^N/factorial(N)+ana_Pdmin(i,j);
end
ana_Pdmin(i,j)=(1-ana_Pdmin(i,j)*exp(-(Nodenum/A)*pi*radio^2))^Nodenum;
j = j+1;
end
end
%*******************draw figure************************
save con_1_range
figure(1)
plot(Radio,simu_Pdmin(1,:),'ro-',Radio,ana_Pdmin(1,:),'k-')
grid on;
legend('\it simPcon','\ita analytical Pcon');
hold on
axis([Radio_down Radio_up 0 1])
xlabel('range(in m)','color','b')
ylabel('prob for d_min','color','b')
title(' P(dmin>=N0 with Euclidian distance metric)')
toc
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -