当前位置:网站首页>随机网络,无标度网络,小世界网络以及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边栏推荐
- Multithreading advanced level
- Four ways to create multithreads
- 原来你是这样的数组,终于学会了
- 阿里云买的40G高效云盘挂载只有20G
- [wechat applet: single or multiple styles, background color, rounded corners]
- Hao looking for a job
- 图片。。。。。
- 相关数据库问题提问。
- Connect to remote server
- Pay attention to this live broadcast and learn about the path to achieve the dual carbon goal of the energy industry
猜你喜欢

1.2 (supplementary)

HuaWei满级大牛首次分享出这份598页网络协议全彩手册

Pycharm shortcut key

RT thread Kernel Implementation (I): threads and scheduling

相关数据库问题提问。

Graphic octet, really top

Fastapi learning Day1

Pay attention to this live broadcast and learn about the path to achieve the dual carbon goal of the energy industry

1.8 - 多级存储

Fastapi learning Day2
随机推荐
A small template (an abstract class, a complete process is written in a method, the uncertain part is written in the abstract method, and then the subclass inherits the abstract class, and the subclas
MySQL中的InnoDB引擎
Analysis of startup process of gazebo multi computer simulation
Deep learning --- the weight of the three good students' scores (3)
Pycharm shortcut key
1.6 - CPU组成
Getting started with research
ES6 arrow function
Usage of case, casez and casex statements in Verilog
Basic questions (I)
A complete performance test process
Base64 explanation: playing with pictures Base64 encoding
Set in set (III)
Centos8 install redis
Rhcsa day 3
Bat 使用细节2
Jgaurora A8 configuration file
Detailed description of methods in the interface
01. regular expression overview
深度学习---三好学生各成绩所占权重问题(3)