require(igraph)
##Create random International Trade Network (igraph object)
ITN<-erdos.renyi.game(50,0.05,directed = TRUE)
##Add edge weights
E(ITN)$weight<-runif(ecount(ITN), 0, 1)
##Add vertex names
V(ITN)$name<-1:vcount(ITN)
##Implement core-periphery algorithm
ITNcp<-core_periphery_weighted(ITN,"directed")
Run the code above in your browser using DataLab