Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/347.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python graph_工具:更快地访问顶点/边属性_Python_Graph Algorithm_Graph Tool - Fatal编程技术网

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)