Python graph_工具:更快地访问顶点/边属性
我想加快顶点/边属性访问过程 对于顶点属性访问,我找到了一种优化的方法,但是对于边属性访问,它对我来说并不是那么简单 顶点属性的思想是直接修改内部数组(Python graph_工具:更快地访问顶点/边属性,python,graph-algorithm,graph-tool,Python,Graph Algorithm,Graph Tool,我想加快顶点/边属性访问过程 对于顶点属性访问,我找到了一种优化的方法,但是对于边属性访问,它对我来说并不是那么简单 顶点属性的思想是直接修改内部数组(a属性) 比如说 vfilt = g.new_vertex_property('bool') for i in range(9999): vfilt.a[int(i % n)] = random.randint(0, 1) (注意vfilt.a非vfilt) 而不是使用: vfilt = g.new_vertex_property('
a
属性)
比如说
vfilt = g.new_vertex_property('bool')
for i in range(9999):
vfilt.a[int(i % n)] = random.randint(0, 1)
(注意vfilt.a
非vfilt
)
而不是使用:
vfilt = g.new_vertex_property('bool')
for i in range(9999):
vfilt[int(i % n)] = random.randint(0, 1)
但是,对于edge,我不确定edge与其属性数组中的内部索引之间的映射
我的问题是:
- 如何优化边缘属性访问
- 是否有其他方法可以优化顶点属性
- 怎么样
for e in g.edges():
vfilt[e] = random.randint(0, 1)
类似地,对于顶点:
for v in g.vertices():
vfilt[v] = random.randint(0, 1)