I am trying to generate a directed and connected scale-free network in R, such that, the in- and out-degrees of the network follow a power-law. I tried the below methods,
g<-sample_fitness_pl(10000, 1000000, 2.7, 2.7)generates a network with a in-/out-degree distribution that does not follow a power-lawThe following function generates power-law distributions of the in- and out-degrees of the nodes, however, the resulting network is not even weakly connected,
N <- 10000
g <- sample_fitness(10*N, sample((1:50)^-2, N, replace=TRUE),sample((1:50)^-2, N, replace=TRUE))
I appreciate any comments that help me learn more about it.
As explained in the documentation, the function
sample_fitness_pl()generates a non-growing random graph with expected power-law degree distributions. We can verify this by plotting the (in-) degree distribution and fitting a power-law distribution function f(x) = c.x^(-α) with non-linear least-square (nls) model.which shows that the degree distribution can be approximated by the power-law distribution f(x) = 3281 . x ^(-0.95), as shown below (the red curve represents the fitted distribution):
Also, the
log-logplot below shows resemblance to power-law distribution, except possibly a few nodes with low in-degree values (we can remove them?)Also, we can find that the graph is connected, since the number of components is 1