Permalink
##
Matlab-Programs-for-Nonlinear-Dynamics/

Go to file
Cannot retrieve contributors at this time

# Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

##
Matlab-Programs-for-Nonlinear-Dynamics/**clusterstats.m**

Go to file
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

64 lines (51 sloc)
1.35 KB

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters

% function[N,e,avgdegree,maxdegree,mindegree,numclus,meanclus,Lmax,L2,LmaxL2,meandistance,diam] = clusterstats(node) | |

% Generates statistics on selected graphs | |

% N = size of network | |

% e = number of edges | |

% avgdegree = average degree | |

% maxdegree = maximum degree | |

% mindegree = minimum degree | |

% numclus = number of clusters | |

% meanclus = cluster coef | |

% Lmax = maximum eigenvalue | |

% L2 = second eigenvalue | |

% LmaxL2 = ratio of Lmax to L2 | |

% meandistance = mean of the distances | |

function [N,e,avgdegree,maxdegree,mindegree,numclus,meanclus,Lmax,L2,LmaxL2,meandistance,diam] = clusterstats(node) | |

[dum,N] = size(node); | |

[A,degree,Lap] = adjacency(node); | |

e = sum(degree)/2; % number of edges | |

avgdegree = mean(degree); | |

maxdegree = max(degree); | |

mindegree = min(degree); | |

loop2 = trace(A^2); | |

[cluscoef,eicoef,clus,ei] = clustercoef(node); | |

meanclus = cluscoef; | |

dis = node2distance(node); | |

meandistance = mean(mean(dis))*(N^2/(N*(N-1))); | |

diam = max(max(dis)); | |

Lam = eig(A); | |

LamL = eig(Lap); | |

Lmax = LamL(N); | |

% Calculate number of disconnected clusters | |

dflag = 0; loop = 0; cnt = 0; | |

while dflag == 0 | |

loop = loop + 1; | |

if loop <=N | |

if LamL(loop) < 0.1/N | |

cnt = cnt + 1; | |

else | |

dflag = 1; | |

end | |

else | |

dflag = 1; | |

end | |

end | |

numclus = cnt; | |

if numclus == 1 | |

L2 = LamL(2); | |

LmaxL2 = Lmax/L2; | |

else | |

L2 = 0; | |

LmaxL2 = 0; | |

end | |