Hi,
I am trying to generate a power law degree distribution using barabasi_albert
from Graphs.jl. I am having trouble replicating the figure 4 on page 7 of this resource. Please forgive me in advance if I am doing something wrong, or have a conceptual misunderstanding. My understanding is that the slope of the degree distribution should be close to -3 in log space. In the example provided in the link, the slope is -2.79. However, I obtain -2.12. Can someone please provide some guidance?
Thank you!
Code
using CurveFit
using Graphs
using Plots
graph = barabasi_albert(100_000, 3, 3; is_directed = true)
degrees = degree(graph)
unique_degrees = unique(degrees)
degree_probs = map(d -> mean(d .== degrees), unique_degrees)
log_log_plot = Plots.scatter(
unique_degrees,
degree_probs,
xaxis = (:log10, font(8)),
yaxis = (:log10, font(8)),
grid = false,
leg = false,
markersize = 2.5,
xlabel = "degree",
ylabel = "probability",
)
fit = curve_fit(LinearFit, log10.(unique_degrees), log10.(degree_probs))
plot!(unique_degrees, 10 .^ fit.(log10.(unique_degrees)), color = :black)
plot!(1:1000, (1:1000).^(-3), color = :blue)