I have a simple problem, I would like to measure the global clustering coefficient for a random graph. Here is my code:
GlobalClusteringCoefficient[RandomGraph[DegreeGraphDistribution[
{2, 1, 1, 1, 1, 2, 1, 3, 3, 1, 1, 2, 2, 2, 2,1, 1, 1, 7, 3, 3, 3, 1, 2, 1}], 10000]]
This is just supposed to create 10000 random graphs, with each vertex in each graph having a fixed number of edges. The error I get is as follows:
GlobalClusteringCoefficient::graph: A graph object is expected at position 1 in GlobalClusteringCoefficient
I tried wrapping everything before the clustering function as follows:
Graph[[RandomGraph[DegreeGraphDistribution[
{2, 1, 1, 1, 1, 2, 1, 3, 3, 1, 1, 2, 2, 2, 2,1, 1, 1, 7, 3, 3, 3, 1, 2, 1}], 10000]]]
And it gives the same error. Anyone know how to convert the random graph generated into a graph object?
EDIT:
So I had in mind to create a For-loop which would go from i = 1
until 10,000
-- but this saved me a lot of computational power. Now I have this:
Mean[GlobalClusteringCoefficient /@
RandomGraph[DegreeGraphDistribution[
{2, 1, 1, 1, 1, 2, 1, 3, 3, 1, 1, 2, 2, 2, 2, 1, 1, 1, 7, 3, 3, 3, 1, 2, 1}], 10000]]
I get a value of 4587/86000
, which is almost too good to be true -- is this really calculating the mean of all 10000 cluster coefficients?
I am a little surprised because I have been using Mathematica for a total of one day, but this solved the issue far faster than R.