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

资源简介

matlab复杂网络代码,很好用希望大家喜欢

资源截图

代码片段和文件信息

clc;
clear;
mat=load(‘e:\exam\find_coremembers\reference38.txt‘);
n=length(mat);
m=sum(sum(mat))/2;
 
vs=[1:n];   %vs are the vertices which need to be recalculate
for i1=1:m
    smat=zeros(n);
    %calculate the shortest-path betweenness
    for i2=1:length(vs)
        %BFS
        ln=0;   %number of leaves
        D=zeros(1length(vs))-1;
        D(vs(i2))=0;
        W(vs(i2))=1;
        pah=1;pat=1;    %two pointers indicate the index of array
        array(pat)=vs(i2);
        pat=pat+1;
        %calculate the distances and weight of vertices
        while(pah            tp=array(pah);
            leaf=1; %assume tp is a leaf
            for i3=1:length(vs)
                if(mat(vs(tp)vs(i3)))
                    if(D(vs(i3))==-1)
                        leaf=0; %tp isn‘t a leaf
                        array(pat)=vs(i3);
                        pat=pat+1;
                        D(vs(i3))=D(vs(tp))+1;
                        W(vs(i3))=W(vs(tp));
                    elseif(D(vs(i3))==D(vs(tp))+1)
                        W(vs(i3))=W(vs(i3))+W(vs(tp));
                    end
                end
            end
            if(leaf)
                ln=ln+1;
                leaves(ln)=tp;
            end
            pah=pah+1;
        end
        %calculate the betweenness of the edges
        tvs=vs;
        for i3=1:length(tvs

评论

共有 条评论