The establishment of WS-Small-world Network and the method of its basic features

Source: Internet
Author: User

The WS-Small World Network is a basic primer for complex networks, though fundamental, but extremely important, and contains many of the most important ideas in the subject of complex networks. First, a brief introduction to the WS Small World Network, is a very small average shortest path and a very high clustering coefficient of a network, popular point, is to imitate the daily life of the connection between a network of people, and then a little more popular, the big road selected two people do not know, you will find that they just through four or five people introduced , you know, these four or five people, they are the distance, called the shortest path. Another example, Tom and Jack are good friends, one day they chat, suddenly found that Mary is Tom's high school classmate, is Jack's college classmate, fate, this fate a quantification, called the cluster coefficient.

Generally do this experiment, with 1000 points to imitate 1000 people, from the rule map (professional term called nearest neighbor coupling network), after the random re-connected (with the specified re-connected rules), began to do analysis (at this time, there are lines, representing the understanding, no connection, representatives do not know).

First, you need to install MATLAB (cover your face, see what this article is sure to know), and then, begin to hit the code according to the rules and formulas, the code reads as follows

% Small World Network

function ws_worldnet (n,k);

Tic

%n=400;% Random node points

%k=2;% Left (right) nearest node count


% Build Node

%angle=0:2*pi/n:2*pi-2*pi/n;

%x=100*sin (angle);

%y=100*cos (angle);


% Calculation L0

B=zeros (n);% full 0 N-dimensional matrix

For I=1:n

For J=i+1:i+k

Jj=j;

If J>n

Jj=mod (J,n);

End

B (I,JJ) = 1;

B (jj,i) = 1;

End

End

% calculation L0 The shortest path between nodes without the need for a broken edge to be re-connected directly

D=b;

For I=1:n

For J=1:n

If D (i,j) ==0

If I==j

D (I,J) = 0;

Else

D (i,j) =inf;

End

End

End

End

The e=b;% Matrix E is an adjacency matrix that has been transformed and is used only to calculate the cluster coefficients C0

For N=1:n

For I=1:n

For J=1:n

If D (i,n) +d (n,j) <d (I,J)

D (i,j) =d (i,n) +d (N,J);

End

End

End

End

L0=sum (sum (D))/(n (N-1));

%disp (D);



% Compute Cluster coefficients C0

Ci0=zeros (n,1);

For I=1:n

Aa=find (E (i,:) ==1);% adjacency nodes of the matrix are searched by rows

If IsEmpty (AA)

Ci0 (i) =0;% if not then the number of neighbor nodes I is 0

Else

M1=length (AA);

If M1==1

Ci0 (i) =0;% the number of neighbor nodes is only 1, the cluster coefficient of the point is 0 (1 is also possible)

Else

B1=e (AA,AA);% Special Note 1

Ci0 (i) =length (Find (B1==1))/(M1* (m1-1));

End

End

End

C0=sum (Ci0)/n;

%disp (C0);



% generates adjacency matrices, simulating connections between nodes

For x=1:14

P (x) =1/(2^ (x-1));

For y=1:20

A=zeros (n);% full 0 N-dimensional matrix

For I=1:n

For J=i+1:i+k

Jj=j;

If J>n

Jj=mod (J,n);

End

A (I,JJ) = 1;

A (jj,i) = 1;

End

End


% reconnect based on probability of Broken edge (random re-connect)


For I=1:n

For J=i+1:n

If A (i,j) ==1

P1 (y) =rand (n);

If P1 (y) <p (x)

A (I,J) = 0; A (J,i) = 0;

Rand_point=unidrnd (N);

While Rand_point==i

Rand_point=unidrnd (N);

End

A (I,rand_point) = 1;

A (rand_point,i) = 1;

End

End

End

End



% calculates CI based on the adjacency matrix after re-interconnection

Ci0=zeros (n,1);

E=a;

For I=1:n

Aa=find (E (i,:) ==1);% adjacency nodes of the matrix are searched by rows

If IsEmpty (AA)

Ci0 (i) =0;% if not then the number of neighbor nodes I is 0

Else

M1=length (AA);

If M1==1

Ci0 (i) =0;% the number of neighbor nodes is only 1, the cluster coefficient of the point is 0 (1 is also possible)

Else

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.