jsexauer / networkx_viewer

Interactive GUI for NetworkX graphs
GNU General Public License v3.0
137 stars 27 forks source link

networkx version 2.0 not working with networkx-viewer #17

Closed joker234 closed 4 years ago

joker234 commented 6 years ago

I wanted to use networkx-viewer after a long time break. Installed a new virtual environment with these versions of the packages:

networkx (2.0)
networkx-viewer (0.2.0)

If I want to perform a minimal example I got the following error:

Traceback (most recent call last):
  File "/home/…/create-network.py", line 33, in <module>
    app = Viewer(G)
  File "/home/…/lib/python3.6/site-packages/networkx_viewer/viewer.py", line 277, in __init__
    EdgeTokenClass=TkPassthroughEdgeToken, **kwargs)
  File "/home/…/lib/python3.6/site-packages/networkx_viewer/viewer.py", line 34, in __init__
    self.canvas = GraphCanvas(graph, width=400, height=400, **kwargs)
  File "/home/…/lib/python3.6/site-packages/networkx_viewer/graph_canvas.py", line 85, in __init__
    self._plot_graph(graph)
  File "/home/…/lib/python3.6/site-packages/networkx_viewer/graph_canvas.py", line 742, in _plot_graph
    layout = self.create_layout(graph, scale=scale, min_distance=50)
  File "/home/…/lib/python3.6/site-packages/networkx_viewer/graph_canvas.py", line 955, in create_layout
    pos= nx.layout._rescale_layout(pos,scale=scale)
AttributeError: module 'networkx.drawing.layout' has no attribute '_rescale_layout'

Important part of the source code:

G = nx.Graph()

… # adding some nodes and edges

app = Viewer(G)
app.mainloop()

I think this error results in the change of networkx.drawing.layout, like you can see in the documentation. There is no _rescale_layout function anymore. Maybe the rescale_layout would do the same for the viewer. Compare v1.11 with v2.0.

Is it possible for you to adjust your awesome package to networkx v2?

shadowao commented 6 years ago

Maybe networkx1.x can sovle your problem. You can alse see this. It also can draw dynamic network graph. Just Run it.

joker234 commented 6 years ago

yes. 1.x would solve this problem, I'm pretty sure. But the interface for networkx changed a bit so I would have to check any networkx function I'm using right now. The linked tool was not working out of the box. (No documentation on how to get it run in less than 30 minutes, too.)

So I'm now stuck at using gephi, but thanks for your help :)

P.S.: This issue is still valid. It would be awesome, if anyone has the time to fix it, and should only take a few hours.

afeser commented 4 years ago

Hi,

I have the same problem, but it seems the repository is not up-to-date. I will solve it if no other solution exists; however, I wonder whether creating a new file for the v2 code or adding if nx.__version__ statements would give the best result.

Thanks!

Edit: I wrote for networkx v2, in case of still somebody needs it. https://github.com/afeser/networkx_viewer/tree/networkx_version2 Any contribution is welcome, please don't hesitate to submit bugs.

jsexauer commented 4 years ago

New version released under 0.3.0. Thanks @afeser for doing the leg work!