当前位置:网站首页>随机网络,无标度网络,小世界网络以及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边栏推荐
- Four tips in numpy
- Bat 使用细节2
- 1.6 - CPU组成
- Bat usage details 2
- 1.8 - 多级存储
- Why does the verification code not refresh when clicked
- RT thread Kernel Implementation (I): threads and scheduling
- DXP copper laying settings
- Notes of the first week of 2021 Chengdu Arts and Sciences cloud computing intensive training class
- Completabilefuture: from understanding to mastering, here are all you want to know
猜你喜欢

Centos8 install redis

Gazebo model modification

1.5 - 逻辑运算

Why does ETL often become ELT or even let?

DHCP operation

Verilog中case,casez,casex语句的用法

DXP copper laying settings

Huawei full-scale Daniel shared the 598 page full-color Manual of network protocols for the first time

GO安装以及配置(1)

Judge whether H5 is in wechat environment or enterprise wechat environment at both ends
随机推荐
程序猿入门攻略(十一)——结构体
Notes of the first week of 2021 Chengdu Arts and Sciences cloud computing intensive training class
IO stream (file class introduction)
High performance distributed execution framework ray
相关数据库问题提问。
gazebo/set_ model_ State topic driving UAV model through posture
1.6 - CPU组成
Connect to remote server
ini解析学习文档
Rotate dimension tool rolabelimg
Introduction to neural networks
583. deleting two strings - Dynamic Planning
HuaWei满级大牛首次分享出这份598页网络协议全彩手册
Using C language pure for loop to implement ilovey
图像处理7-图像增强
Is it safe to open an account online? Can you open an account to speculate on the Internet?
MySQL中的InnoDB引擎
ini解析學習文檔
Px4 control mode summary
Wechat applet mall project