How To Seed Graph Generator In Python-igraph?
Is there any way to seed the following Watts-Strogatz graph generated using python-igraph, so that each time I run the script I get the same realization of SW graph ? import igrap
Solution 1:
igraph uses the built-in RNG of Python so you can seed that:
In [1]: import random
In [2]: random.seed(1234)
In [3]: g=Graph.Watts_Strogatz(1, 100, 2, 0.25)
In [4]: random.seed(1234)
In [5]: g2=Graph.Watts_Strogatz(1, 100, 2, 0.25)
In [6]: g.get_edgelist() == g2.get_edgelist()
Out[6]: True
Post a Comment for "How To Seed Graph Generator In Python-igraph?"