Closed A-Gray-Cat closed 6 years ago
I'm sorry you ran into this problem. Unfortunately for debugging, when I run this line of code I don't get any such error. Could you give me a bit more information, such as what version of python you are running, which operating system you are using, and which version of networkx you are using? Also, were there any modifications you made to the example notebook?
My first suggestion would be the following: Make sure you are using the latest version of our code, either by pulling from our github again or pip updating the visJS2jupyter package (depending on how you are using the visJS2jupyter code).
Another thing to note: For more recent versions of networkx, G.edges() no longer returns a list, but rather an EdgeView object, which may explain why you need to caste edges to a list.
I got the same error, and I also solve it promoting edges as a list.
I am using Python 3.5, and Networkx 2.1.
I did edges = list(edges)
right after creating the object.
Also, I had to add the positions for x,y using:
nodes_dict = [{"id":n,"x":pos[n][0]*10,"y":pos[n][1]*10} for n in nodes]
The problem is with Networkx 2.1. nx.Graph().edges() in version 2 of Networkx returns an EdgeView object, not a list of edges. So that's why you have to cast edges to a list. I have also informed the writer of that notebook that the x and y positions are missing from the nodes_dict.
Any update for the bugs?
I'm very new to the python, so hope this be fixed.
edges_dict = [{"source":node_map[edges[i][0]], "target":node_map[edges[i][1]], "title":'test'} for i in range(len(edges))]
When I ran this, it gave me this error: 'int' object is not iterable.
Then I casted variable edges to list, and it worked.