我想从python-igraph
中的图形对象中删除边属性。等价的igraph R函数被巧妙地称为^{
如果没有,还有别的办法吗?(我尝试了一个简单的g.es['edge_attr']= []
,但没有成功)。你知道吗
示例代码
g = ig.Graph.Tree(10, 2) #Generate random graph
g_betweenness = g.betweenness() #Calculate betweenness for graph
g['betweenness'] = betweenness #Assign betweenness as edge attribute
print(g.attributes())
g['betweenness'] = [] #Attempt to remove betweenness edge attribute (incorrect)
print(g.attributes())
输出
['betweenness']
['betweenness']
所需输出
['betweenness']
[]
您可能无法将其设置为空数组,但您关于直接更改
EdgeSequence
的直觉已经相当不错了。您只需使用Python的内部del()
删除参数,下面我提供了一个最小的示例:相关问题 更多 >
编程相关推荐