igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] fruchterman reingold


From: Tamas Nepusz
Subject: Re: [igraph] fruchterman reingold
Date: Fri, 1 Nov 2019 17:20:58 +0100


 In python igraph version, g=Graph(); g.layout_fruchterman_reingold(weights=edgeweightlist) function in igraph produces different layout of graph each time for same graph nodes and same edgeweightlist. How to turn off this randomness to produce the same graph each time?

Just set the seed of the random number generator to an arbitrary fixed value before calling the layout function:

>>> from random import seed
>>> from igraph import Graph
>>> g=Graph.GRG(100, 0.2)
>>> seed(1234)
>>> lo=g.layout("fr")
>>> lo[:10]
[[-7.319725822182468, -2.5222146293950525], [-6.042515482711504, 6.60729011892673], [-7.766841439471336, -1.072218029492348], [-7.868509175067755, -6.519283541476223], [-6.607952925294913, -5.512660296266184], [-6.896034600003832, 3.5033722770007247], [-7.439334008796665, -0.18725281663352827], [-6.568594470049888, -6.971425023807268], [-7.610905586198632, -6.890279777715495], [-7.220889614908134, -1.5430061492566187]]
>>> seed(1234)
>>> lo=g.layout("fr")
>>> lo[:10]
[[-7.319725822182468, -2.5222146293950525], [-6.042515482711504, 6.60729011892673], [-7.766841439471336, -1.072218029492348], [-7.868509175067755, -6.519283541476223], [-6.607952925294913, -5.512660296266184], [-6.896034600003832, 3.5033722770007247], [-7.439334008796665, -0.18725281663352827], [-6.568594470049888, -6.971425023807268], [-7.610905586198632, -6.890279777715495], [-7.220889614908134, -1.5430061492566187]]

T.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]