14,668,125 members

coordinates <- matrix(c(0.809,0.588,0.309,0.951,-0.309,0.951,-0.809,0.588,-1,0,-0.809,-0.588,-0.309,-0.951,0.309,-0.951,0.809,-0.588,1,0), ncol=2)

...and a quadratic matrix Y as an adjacency matrix:

adjacency <- matrix(c(0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0), ncol=10)

Unfortunately I can only use the standard R Library (that which is pre-installed) and that's why I'm having a hard time figuring it out...

So far I have this code but the graph it creates is quite "ugly" and gives me a ton of errors:

plotGraph <- function(B){ coordinates <- matrix(c(0.809,0.588,0.309,0.951,-0.309,0.951,-0.809,0.588,-1,0,-0.809,-0.588,-0.309,-0.951,0.309,-0.951,0.809,-0.588,1,0), ncol=2) adjacency <- matrix(c(0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0), ncol=10) plot(coordinates) idx <- which(adjacency>0, arr.ind = T) number = ncol(adjacency) * nrow(adjacency) for(i in 1:number){ arrows(coordinates[idx[i,1],1], coordinates[idx[i,1],2], coordinates[idx[i,2],1], coordinates[idx[i,2],2]) } }

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject,
503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada
+1 416-849-8900 x 100