14,699,563 members
See more:
In R programming - How do I plot a network visualization graph given a matrix X with a 2 column coordinate system:

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...

What I have tried:

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)

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])
}
}
Posted
Updated 10-May-17 3:57am
v2

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

Top Experts
Last 24hrsThis month
 CPallini 200 Richard Deeming 190 OriginalGriff 185 Richard MacCutchan 160 CHill60 55
 OriginalGriff 825 Richard Deeming 455 CPallini 395 Richard MacCutchan 330 Patrice T 210

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900