r - Graph from adjacency list -
i have adjacency list , want visualize them , processing on it. there package efficiently. see there lot of graph packages confused among them. can me on this?
$`825` [1] 824 $`824` [1] 823 $`823` [1] 822 $`822` [1] 821 $`821` [1] 820 777 $`820` [1] 819 816 789 787 785 783 $`777` [1] 776
above adjacency list. below graph want.
825 | 824 | _______ 783 823 / | /________ 785 822 / | /__________ 787 821 -- 820 | \__________ 789 777 \ | \________ 816 776 \ \______ 819
thanks.
mylist <- list(2,c(1,3),c(2,4),c(3,1)) names(mylist) <- c(1,2,3,4) # list #make in igraph format myadj <- stack(mylist) #> values ind #> 1 2 1 #> 2 1 2 #> 3 3 2 #> 4 2 3 #> 5 4 3 #> 6 3 4 #> 7 1 4 #plot library(igraph) g<-graph.data.frame(myadj) plot(g)
Comments
Post a Comment