当前位置:网站首页>随机网络,无标度网络,小世界网络以及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边栏推荐
- c# - C#用fo-dicom对CT图像的PixelData进行处理和转换
- Installing googleplay environment on Huawei mobile phones
- Introduction to neural networks
- 深度学习---三好学生各成绩所占权重问题(3)
- uniapp 微信小程序返回上一页并刷新
- Simple example of class template
- 1.6 - CPU composition
- Analysis of startup process of gazebo multi computer simulation
- It turns out that you are such an array. You have finally learned
- File operation io-part1
猜你喜欢
随机推荐
手机开户一般哪个证券公司好?还有,在线开户安全么?
880. decoded string at index
Four tips in numpy
ini解析學習文檔
[untitled]
Getting started with research
INI analyse les documents d'apprentissage
2020-10-06
Uniapp wechat applet returns to the previous page and refreshes
从底层结构开始学习FPGA----RAM IP核及关键参数介绍
圖像處理7-圖像增强
Image processing 7- image enhancement
It turns out that you are such an array. You have finally learned
HuaWei满级大牛首次分享出这份598页网络协议全彩手册
Introduction to neural networks
My experience in functional testing for so many years
基础刷题(一)
Control method of UAV formation
Bat usage details 2
与MQTT的初定情缘









