当前位置:网站首页>随机网络,无标度网络,小世界网络以及NS小世界的性能对比matlab仿真
随机网络,无标度网络,小世界网络以及NS小世界的性能对比matlab仿真
2022-06-30 06:39:00 【fpga和matlab】
1.软件版本
matlab2021a
2.系统实现过程
1.随机网络(random network)
网络的场景如下所示:

其性能指标如下:
下面,通过不同的攻击类型,来判断网络的鲁棒性,仿真结果如下所示:
clc;
clear;
close all;
warning off;
addpath 'func\'
rng(1);
%产生随机网络
%Num--顶点个数,Per--连接概率,avg_length--边的平均长度
Num = 100;
Per = 0.036;
avg_length = 100;
[matrix,x,y] = func_Random_network(Num,Per,avg_length);
figure;
plot(x,y,'r.','Markersize',18);
hold on;
for i=1:Num
for j=i+1:Num
if matrix(i,j)~=0
plot([x(i),x(j)],[y(i),y(j)],'b--','linewidth',1);
hold on;
end
end
end
hold off
%计算相应的指标
[Cc,Cc_avg] = func_Cluster_Coeff(matrix);
disp(['聚类系数为:',num2str(Cc_avg)]);
[Dds,Dds_avg,M,P_Dds]= func_Degree_Distribution(matrix);
disp(['平均度为:',num2str(Dds_avg)]);
[Lens,Lens_avg] = func_Path_Length(matrix);
disp(['平均路径长度为:',num2str(Lens_avg)]);
figure;
subplot(211);
bar([1:Num],Dds);
xlabel('节点编号');
ylabel('节点的度');
subplot(212);
bar([0:M],P_Dds,'r');
xlabel('节点的度');
ylabel('节点度的概率');
2.无标度网络 (scale-free network)

其性能指标如下:

下面,通过不同的攻击类型,来判断网络的鲁棒性,仿真结果如下所示:

clc;
clear;
close all;
warning off;
addpath 'func\'
rng(1);
%产生随机网络
%Num--顶点个数,Per--连接概率,avg_length--边的平均长度
Num = 100;
[matrix,x,y] = func_scalefree_network(Num);
figure;
plot(x,y,'r.','Markersize',18);
hold on;
for i=1:Num
for j=i+1:Num
if matrix(i,j)~=0
plot([x(i),x(j)],[y(i),y(j)],'b--','linewidth',1);
hold on;
end
end
end
hold off
%计算相应的指标
[Cc,Cc_avg] = func_Cluster_Coeff(matrix);
disp(['聚类系数为:',num2str(Cc_avg)]);
[Dds,Dds_avg,M,P_Dds]= func_Degree_Distribution(matrix);
disp(['平均度为:',num2str(Dds_avg)]);
[Lens,Lens_avg] = func_Path_Length(matrix);
disp(['平均路径长度为:',num2str(Lens_avg)]);
figure;
subplot(211);
bar([1:Num],Dds);
xlabel('节点编号');
ylabel('节点的度');
subplot(212);
bar([0:M],P_Dds,'r');
xlabel('节点的度');
ylabel('节点度的概率');
3.小世界 network

其性能指标如下:

下面,通过不同的攻击类型,来判断网络的鲁棒性,仿真结果如下所示:

clc;
clear;
close all;
warning off;
addpath 'func\'
rng(1);
%产生随机网络
%Num--顶点个数,Per--连接概率,avg_length--边的平均长度
Num = 100;
K = 3;
Per = 0.4;
[matrix,x,y] = func_WS_network(Num,K,Per);
figure;
plot(x,y,'r.','Markersize',18);
hold on;
for i=1:Num
for j=i+1:Num
if matrix(i,j)~=0
plot([x(i),x(j)],[y(i),y(j)],'b--','linewidth',1);
hold on;
end
end
end
hold off
%计算相应的指标
[Cc,Cc_avg] = func_Cluster_Coeff(matrix);
disp(['聚类系数为:',num2str(Cc_avg)]);
[Dds,Dds_avg,M,P_Dds]= func_Degree_Distribution(matrix);
disp(['平均度为:',num2str(Dds_avg)]);
[Lens,Lens_avg] = func_Path_Length(matrix);
disp(['平均路径长度为:',num2str(Lens_avg)]);
figure;
subplot(211);
bar([1:Num],Dds);
xlabel('节点编号');
ylabel('节点的度');
subplot(212);
bar([0:M],P_Dds,'r');
xlabel('节点的度');
ylabel('节点度的概率');
4.NS小世界 network

其性能指标如下:

下面,通过不同的攻击类型,来判断网络的鲁棒性,仿真结果如下所示:

clc;
clear;
close all;
warning off;
addpath 'func\'
rng(1);
%产生随机网络
%Num--顶点个数,Per--连接概率,avg_length--边的平均长度
Num = 100;
K = 2;
Per = 0.005;
[matrix,x,y] = func_NW_network(Num,K,Per);
figure;
plot(x,y,'r.','Markersize',18);
hold on;
for i=1:Num
for j=i+1:Num
if matrix(i,j)~=0
plot([x(i),x(j)],[y(i),y(j)],'b--','linewidth',1);
hold on;
end
end
end
hold off
%计算相应的指标
[Cc,Cc_avg] = func_Cluster_Coeff(matrix);
disp(['聚类系数为:',num2str(Cc_avg)]);
[Dds,Dds_avg,M,P_Dds]= func_Degree_Distribution(matrix);
disp(['平均度为:',num2str(Dds_avg)]);
[Lens,Lens_avg] = func_Path_Length(matrix);
disp(['平均路径长度为:',num2str(Lens_avg)]);
figure;
subplot(211);
bar([1:Num],Dds);
xlabel('节点编号');
ylabel('节点的度');
subplot(212);
bar([0:M],P_Dds,'r');
xlabel('节点的度');
ylabel('节点度的概率');
%A12-27边栏推荐
- Static routing job
- 0基础转行软件测试,如何实现月薪9.5k+
- Win10 /11 开热点无法上网问题
- 史上最全一句话木马
- Collection and method of traversing collection elements (1)
- Gazebo model modification
- Joseph problem C language
- C language final experiment report (student achievement management system) source code
- Improve simulation speed during ROS and Px4 joint simulation
- ETL为什么经常变成ELT甚至LET?
猜你喜欢
随机推荐
Use of observer mode and status mode in actual work
High performance distributed execution framework ray
HuaWei满级大牛首次分享出这份598页网络协议全彩手册
C语言:练习题三
图解八股,真的太顶了
Uniapp wechat applet returns to the previous page and refreshes
List in set (2)
Px4 control mode summary
Why does the verification code not refresh when clicked
圖像處理7-圖像增强
How does Altium designer hide some temporarily unnecessary classes, such as GND
Basic questions (I)
Learn fpga---ram IP core and key parameters from the bottom structure
Is it safe to open an account online? Can you open an account to speculate on the Internet?
神经网络入门
Loading class `com. mysql. jdbc. Driver‘. This is deprecated. The new driver class is `com. mysql. cj. jdb
Unable to access the Internet at win10 /11 hotspot
Four tips in numpy
Dynamic routing job
Completabilefuture: from understanding to mastering, here are all you want to know
![[untitled]](/img/6c/df2ebb3e39d1e47b8dd74cfdddbb06.gif)






![[wechat applet: single or multiple styles, background color, rounded corners]](/img/01/0381915591b0d3c13afbba4d50952d.png)

