【发布时间】:2015-12-03 17:47:30
【问题描述】:
所以我试图生成一个随机有向图,使得每个顶点都有 3 个入节点和 1 个出节点。但是图形工具似乎卡在 deg_sampler() 函数中。
from graph_tool.all import *
def deg_sampler():
return 1,2
g = random_graph(1000,deg_sampler,verbose=True)
运行代码后出现此错误
adding vertices: 1000 of 1000 (100%)
fixing average degrees. Total degree difference: 1000^CTraceback (most recent call last):
File "code.py", line 6, in <module>
g = random_graph(1000,deg_sampler,verbose=True)
File "/usr/lib/python2.7/dist-packages/graph_tool/generation/__init__.py", line 384, in random_graph
_get_rng(), verbose, True)
File "/usr/lib/python2.7/dist-packages/graph_tool/generation/__init__.py", line 379, in <lambda>
sampler = lambda i: deg_sampler()
KeyboardInterrupt
【问题讨论】:
-
您是否试图在某处复制文本?按 Ctrl-C 会杀死 Python 中正在运行的任何东西。这就是为什么您会在底部看到“
KeyboardInterrupt”。 -
我的意思是我会在大约 30 分钟后退出程序。生成节点需要那么长时间吗?
标签: python graph graph-tool