jaber
jaber

Reputation: 11

Igraph: Extract nodes layout from a network and use it for another

I would like to compare two plots of graphs(an observed graph and a simulated one) that have the exact same nodes. I would like to keep the nodes position fix so I can compare the difference in the edge's distribution. I have tried set.seed but it's just keeping the plot identical every time I run it. Is there a way to take the layout of a graph and use it for the other? Thanks,

Upvotes: 0

Views: 643

Answers (1)

lukeA
lukeA

Reputation: 54237

Fwiw, I guess you can use the layout argument of plot:

library(igraph)
set.seed(1)
g1 <- ba.game(20, dir=F)
g2 <- ba.game(20, dir=F)
par(mfrow = c(1, 2))
coords <- layout.fruchterman.reingold(g1)
plot(g1, layout = coords)
plot(g2, layout = coords)

enter image description here

Upvotes: 2

Related Questions