Initialize the random number generator.
If a is omitted or None, the current system time is used. If randomness sources are provided by the operating system, they are used instead of the system time (see the os.urandom() function for details on availability).
If a is an int, it is used directly.
With version 2 (the default), a str, bytes, or bytearray object gets converted to an int and all of its bits are used.
With version 1 (provided for reproducing random sequences from older versions of Python), the algorithm for str and bytes generates a narrower range of seeds.
Changed in version 3.2: Moved to the version 2 scheme which uses all of the bits in a string seed.
您可以设置种子,使其具有确定性,如:
G = nx.gnp_random_graph(20,0.5,0) # or any other int
代码如下:
将使用当前时间或其他资源初始化PRNG(如
seed=None
)由于networkx是纯python和reuses the standardlib,因此可以归结为python's random module seed:
您可以设置种子,使其具有确定性,如:
最后一行总是输出相同的图形(文档显式地调用int!)。你知道吗
如果你的导师没有修复种子,那么试图复制它就有点假了。你知道吗
相关问题 更多 >
编程相关推荐