-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
📝 Generate a fixed graph with a constant random seed #220
Labels
enhancement
New feature or request
Comments
下面是生成无向图的代码:
|
下面是运行结果: 文件名是
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Generate a fixed undirected graph with a constant random seed
固定随机种子,生成固定的无向图
固定完随机种子之后,算法内部会生成固定的伪随机数,
随机生成无向图的函数
generate_graph()
,会“消耗”这些伪随机数下面的代码,可以在指定无向图的节点数量
num_nodes
,图的生成方式g_type
以及 图的序号valid_i
,直接用代码生成固定的图。无论使用什么设备。我建议使用方案1,避免储存很多表示无向图的txt文件(不用担心文件丢失)。只要指定以下三个信息,就能直接生成无向图,对于这样的
graph_name = 'powerlaw_100_ID042'
,可以用函数直接生成唯一的无向图 :num_nodes=100
g_type=‘powerlaw’
valid_i=42
备注:在生成300个节点的图,我们用的是方案3。在2023-08-17日之后才改成方案1
方案1:将图的序号
valid_i
作为 random seed 的序号,算力消耗最小,要换随机种子方案2:固定随机种子后,消耗定量的随机数值,介于方案1与方案2之间。
方案3:固定随机种子后,直接调用生成函数,自动消耗定量的随机数值,在
valid_i
很大的时候消耗较多算力The text was updated successfully, but these errors were encountered: