• 大小: 3KB
    文件类型: .m
    金币: 1
    下载: 0 次
    发布日期: 2021-05-16
  • 语言: Matlab
  • 标签:

资源简介

计算网络节点收缩后的重要度,并对电源和负荷节点进行归一化

资源截图

代码片段和文件信息

function Z=floyd(ady)
              n=size(a1);               %矩阵维数
              Z=zeros(n1);              %节点重要度向量                           
              %由邻接矩阵a得到直接距离矩阵H
              H=zeros(size(a));
              for i=1:n
                  for j=1:n
                      if j==i
                          H(ij)=0;
                      elseif a(ij)==1
                          H(ij)=1;
                      else
                          H(ij)=inf;
                      end
                  end
              end
              
              %用Floyd法计算节点收缩前的最短距离矩阵D
              D=H;                           
              for k=1:n
                  for i=1:n
                      for j=1:n
                          if D(ik)+D(kj)                              D(ij)=D(ik)+D(kj);                             
                          end 
                      end 
                  end                                    
              end
              
              %计算节点重要度
              D2=zeros(size(D));              
              for i=1:n                  
                  %得到与节点i邻接的节点向量I
                  I=zeros(10);
                  t=0;
                  for j=1:n
                      if a(ij)==1
                          t=t+1;
                          I=[Ij];
                      end
                  end
                  
                %计算收缩前的最短距离矩阵D2
                for p=1:n
                    for q=1:n
                        if p~=i&q~=i
                            if D(pi)+D(iq)==D(pq)
                                D2(pq)=D(pq)-2;
                            elseif D(pi)

评论

共有 条评论

相关资源