lundi 31 octobre 2016

R plot random graph with same structure

I'm creating a random graph in R with the igraph-library.

library(igraph)
g <- erdos.renyi.game(12, 0.25)
par(mfrow=c(1,2))
plot(g)
plot(g)

This creates the following plot:

random graph

As you can see, it creates two different plots - even given the same nodes and edges. How can I make R plot the same plots, so I can highlight some edges/nodes while having the same order.

The goal is to create a random network with some degree of probability that two nodes are connected by an edge (above example is p=0.25 for n=12 nodes). Then this graph is plotted with the nodes on the same spot (even if the node size variies) everytime I plot it.

How do I do this? Note that I'm not limited to g <- erdos.renyi.game(12, 0.25) - it just did the job with the random network quite well.




Aucun commentaire:

Enregistrer un commentaire