I want (bit curious) to know is there any other algorithm possible for preferential attachment network. I want R code. I write something and that is work for me
My Code
t1 <- 50
int.adj.mat <- matrix(c(0,1,1,0), nrow = 2)
p <- c(0.5,0.5)
for (i in 2:t1) {
p <- rowSums(int.adj.mat)/sum(int.adj.mat)
d <- rbinom(i, 1, p)
int.adj.mat <- rbind(cbind(int.adj.mat, d), c(d,0))
}
PA <- matrix(0, nrow = NROW(int.adj.mat), ncol = NCOL(int.adj.mat))
for (i in 1:nrow(int.adj.mat)) {
PA[,i] <- int.adj.mat[,i]
}
library(igraph) #For plotting
network <- graph_from_adjacency_matrix(PA, mode = "undirected")
plot(network, vertex.size = 3, vertex.label = NA)
Output
This code is actually increases the order of adjacency matrix when a new node is arrived in the pre-existing network. There are several article available see (pa1 and pa2) where author describe several algorithms. But it is hard to implement in R. Any improvised version of algorithm written in R is appreciated.
This question is completely for self-study and knowledge purpose.
