Home:ALL Converter>How to remove an edge attribute in python-igraph

How to remove an edge attribute in python-igraph

Ask Time:2019-03-22T09:53:05         Author:Josh

Json Formatter

I want to remove an edge attribute from a Graph object in python-igraph. The equivalent igraph R function is cleverly called delete_edge_attr. I haven't been able to find an equivalent function/method in Python... is there one?

If not, is there another way to do it? (I tried a simple g.es['edge_attr']= [] but this didn't work).

Example Code

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())

Output

['betweenness']
['betweenness']

Desired output

['betweenness']
[]

Author:Josh,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/55291777/how-to-remove-an-edge-attribute-in-python-igraph
yy