I'll show what I'm doing in the moment and after that I'll explain what I'm trying to achieve. I use the following code to generate a large number of Barabási-Albert networks, and after that I plot the degree distribution of these networks.

net = Table[BarabasiAlbertGraphDistribution[100, 2], 5];
graph = RandomGraph /@ net;
degree = VertexDegree /@ graph;
k = Union /@ degree;
prob = Table[ (Table[
  Probability[x >= i, x \[Distributed] deg[[j]]], {i, #}] &@
k[[j]]), {j, 1, Length[k]}];
cdf = Table[Transpose@{k[[i]], prat[[i]]}, {i, 1, Length[prat]}];
ListLogLogPlot[Table[cdf[[i]], {i, 1, 5}]]

From the ListLogLogPlot command I get the following plot: Degree distribution of the Barabas-Albert graphs

Each color represent a dataset from the code above. Since the graphs generated through the Barabasi model are random, I generate a large number of them in order to find the average behavior of the degree distribution in order to compare it with the degree distribution of other network models. However, I can't find a function that works in this kind of datasets, specially because they have different lengths when you are working with large networks (4000-10000 nodes).

I tried using the Flatten and Union functions in order to have only one list with data points and used LinearFit and Interpolation functions without success. After Flatten and Union I have a plot like this:

b = Union[Flatten[cdf,1]]

enter image description here

But even with a list with only one dataset the FitLinear and Interpolation functions won't work. Does anyone have a clue if I can find the average representation of these kind of datasets with Mathematica?


1 Answer 1


You are working with distributions. Instead of averaging, simply combine the data from multiple graphs before visualizing the distribution.

This combines the degrees from 1000 graphs:

degs = Join @@ 
   VertexDegree /@ 
    RandomGraph[BarabasiAlbertGraphDistribution[100, 2], 1000];

Visualizing the "CDF from the right" (survival function) only requires reverse sorting the data.

 Transpose@{ReverseSort[degs], Range@Length[degs]}

enter image description here

Or use Histogram

Histogram[degs, {"Log", Automatic}, {"Log", "PDF"}]

enter image description here

Histogram[degs, {"Log", Automatic}, {"Log", "SurvivalCount"}]

enter image description here

Combining the data first and then histogramming is in fact equivalent to histogramming first and then averaging histograms. Thus, don't try to average. Just combine the data.

  • $\begingroup$ Thanks for the answer! I tried working on the full degree distribution of a huge number of networks but my problem was that I was treating it like an average, not a distribution like you showed. Thanks! $\endgroup$ Commented Mar 26, 2020 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.