require(igraph)
##Create random International Trade Network (igraph object)
gs<-erdos.renyi.game(50,0.05,directed = TRUE)
##Add vertex attributes
V(gs)$LETTER<-rep(LETTERS[1:5],10)
##Add vertex names
V(gs)$name<-1:vcount(gs)
##Calculate mixing matrix
mixing_matrix<-mixing_matrix_igraph(gs,"LETTER")
Run the code above in your browser using DataLab