Reputation: 1
Suppose we want to visualise a network like the one below
library(igraph)
a<- cbind(c(1,2,3,4,5),
c(2,4,1,2,2))
b<- graph.edgelist(a, directed=FALSE)
Is there any way to keep the nodes in the same position apart from setting the coords by hand?? For example, can we edit the graph with tkplot and save the layout so that it remains the same no matter how many times we run the code? By using the function tkplot.getcoords, I manage to save the layout only once. Is repeatablility possible?
Thank you in advance.
Upvotes: 0
Views: 1187
Reputation: 7277
A solution is to set a seed with set.seed
:
library(igraph)
a<- cbind(c(1,2,3,4,5),
c(2,4,1,2,2))
b<- graph.edgelist(a, directed=FALSE)
set.seed(123)
plot(b)
And you'll get this each time you run the code:
Upvotes: 1