# Clustering in Small-World Networks

Clustering can be used to quantify network robustness with respect to perturbation, and a high degree of clustering is one of the features captured by the small-world networks of Watts and Strogatz. In epidemiology, a robust network allows a disease to spread similarly even if the network is perturbed.

#### Compute the global clustering coefficient of a random graph.

 In[1]:= XRandomGraph[WattsStrogatzGraphDistribution[40, 0.05, 5]]
 Out[1]=
 In[2]:= XRandomGraph[WattsStrogatzGraphDistribution[40, 0.05, 5]]; GlobalClusteringCoefficient[%]
 Out[2]=

#### Compute the global clustering coefficients of a set of random graphs.

 In[3]:= X{graphs, coeffs} = Transpose[ SortBy[{#, GlobalClusteringCoefficient[#]} & /@ RandomGraph[WattsStrogatzGraphDistribution[30, 0.1, 3], {10000}], Last]];

#### Create the heat map of selected graphs with respect to the coefficient values.

 In[4]:= Xmin = Min[coeffs]; max = Max[coeffs];
 In[5]:= Xnf = Nearest[coeffs -> graphs];
 In[6]:= Xvalues = Range[min, max, (max - min)/(4^2 - 1)];
 In[7]:= XGrid[Partition[Map[ SetProperty[ First[nf[#]] 1, {VertexStyle -> Directive[White, EdgeForm[White]], EdgeStyle -> White, Background -> ColorData[{"SolarColors", "Reversed"}, Rescale[#, {min, max}]], ImageSize -> {100, 100}}] &, values], 4]]
 Out[8]=