Scale-free network simulation based on Matlab

1. Problem description:

        Scale-free networks have severe heterogeneity connections (in degrees) between nodes which do not have serious uniform distribution of: the network is called a few Hub node point has a very many connections, and most node There are only a few connections. A few Hub points play a leading role in the operation of the scale-free network. Broadly speaking, the scale-free nature of the scale-free network is an inherent property that describes the serious uneven distribution of a large number of complex systems as a whole.

2. Part of the program:

function matrix = FreeScale(X)
%By 201121250314
N = X; m0 = 3; m = 3; %initialize
adjacent_matrix = sparse( m0, m0);%initialize adjacency matrix
for i = 1: m0
    for j = 1:m0
        if j ~= i
            adjacent_matrix(i,j) = 1;
        end
    end
end
adjacent_matrix = sparse(adjacent_matrix);
node_degree = zeros(1,m0+1);
node_degree(2: m0+1) = sum(adjacent_matrix);
for iter = 4:N
    iter
    total_degree = 2*m*(iter- 4)+6;
    cum_degree = cumsum(node_degree);
    choose = zeros(1,m);
    % Select the first vertex connected to the new point
    r1= rand(1)*total_degree;
    for i= 1:iter-1
        if (r1>=cum_degree(i))&( r1<cum_degree(i+1))
            choose(1) = i;
            break
        end
    end
    % 选出第二个和新点相连接的顶点
    r2= rand(1)*total_degree;
    for i= 1:iter-1
        if (r2>=cum_degree(i))&(r2<cum_degree(i+1))
            choose(2) = i;
            break
        end
    end
    while choose(2) == choose(1)
        r2= rand(1)*total_degree;
        for i= 1:iter-1
            if (r2>=cum_degree(i))&(r2<cum_degree(i+1))
                choose(2) = i;
                break
            end
        end
    end
    % Select the third vertex connected to the new point
    r3 = rand(1)*total_degree;
    for i = 1:iter-1
        if (r3>=cum_degree(i))&(r3<cum_degree(i+1) )
            choose(3) = i;
            break
        end
    end
 
        

3. Simulation conclusion:

D00009

Guess you like

Origin blog.csdn.net/ccsss22/article/details/114897072