Hi folks, I have a matrix of 3 columns and 17 lines that represents a graph or a adjacency matrix. I have also a vector of 30 elements with some of the nodes of the graph repeated. seems like: 1. matrix that represents a graph: 1 2 1 1 3 1 1 4 1 2 1 1 2 4 1 3 1 1 4 1 1 4 2 1 2. vector of nodes repeated: 1 1 1 1 1 2 2 3 3 1 1 4 4 4 4 Well, I have tried to do a code to take the repeated nodes and make a spam of the matrix above in a adjacency matrix representation and I get not sucess. The code seems like: mat_spam<-function(mat_rev,vet_adj){ i<-1 while (i<6) { j<-1 while (j<17) { m<-1 while (m<6) { if (mat_rev[i+1,m]==mat_rev[i, m+1]){ mat_rev[i+1,m+1]=0} else{if (mat_rev[i,m+1]==vet_adj[j,1] & mat_rev[i,m+2]==vet_adj[j,2]){ mat_rev[i+1,m+1]=1} else{mat_rev[i+1,m+1]=0}} m<-m+1} j<-j+1} i<-i+1} return(mat_rev)} Anyone has a sugestion how can I do this? The principal question is how to spam an adjacency matrix to a biggest one by repeating nodes that i am representing by a vector. Thanks in advances Francisco Gildemir Ferreira da Silva [[alternative HTML version deleted]]