Runtime Error With Networkx : Dictionary Changed During Iteration While Running A Neural Gas Script
I am trying to run a neural gas network with an older script that doesn't work well with networkx 2 so I modified some things. However I am getting the error : Dictionary changed s
Solution 1:
Here you're looping through the edges of the graph:
for u, v, attributes in self.network.edges(data=True):
But within that loop you modify the edges. So self.network.edges
(which is fundamentally a dictionary) is changing while you're iterating. This isn't allowed by python.
A solution to this is to predefine
edgelist = list(self.network.edges(data=True))
then do
for u, v, attributes in edgelist:
Post a Comment for "Runtime Error With Networkx : Dictionary Changed During Iteration While Running A Neural Gas Script"