Suggestions
Hi,
Great project! This is the first time I see a GUI that let people interface with a neworkx graph.
Just a few ideas:
- Would it be possible to add nodes to the window dynamically? (via a button or ideally: if the user drags&drops a text on the screen, this could create a node using the text as a name)
- Would it be possible to add properties to a node (eg: let's assume a node is an individual, properties could be the name, the age, etc...)
- Would it be possible to add edges easily to the network (eg by selecting 2 nodes and then clicking on a button...
Hi Kurba,
Thanks for your feedback! Regarding your comments:
- While I would like to add capability to add nodes and edges to the graph dynamically though the UI, it is a low priority. Hopefully, one day I will have a chance to do it.
- Adding properties to a node is on the list of things to do pretty soon. When you select a node or edge, I plan to display in tabular form the key-value pairs from the data dict. Let me know if this is what you were thinking.
The latest build has the ability to display attributes for nodes and edges in a panel on the right.
This is a great project and if you need some help let me know. Here is my first impression:
- panning works great
- Zooming (Zoon) not so good, it leaves old edges and you can't get rid of them. Seems like they are on the edges where one of the node on the edge is only connected via that edge.
- I could live with (2) if there was a canvas refresh - which there is "Redraw Plot" - except that this re-scales it and moves everything around losing the beautiful view of the graph I had just setup. Why not just clear the canvas and redraw it? Maybe call it "Refresh Plot" to keep the old functionality.
- When first drawn and subsequent redraws my entire network is not within view.
- It would great if we could save and restore the positions of the nodes in a file.
- Zooming worked on a very simple network I made on the fly vs my "real" network.
v1.10 Ok here is the problem. I have a DiGraph (oh that was another wish to get an arrow or whatever for Directional graphs) where two nodes point to each other.
nw = nx.DiGraph() nw.add_edges_from([(1,2), (2,3), (2,4), (1,4), (3,5), (3,2)]) app = Viewer(nw) app.mainloop()
In a DiGraph 2->3 and 3->2 so the first zoom cause the problem. Maybe both edges get drawn but only one is zoomed.
Here is a quick hack to fix this in GraphCanvas._plot_graph:
# remove redundant edges
e0 = graph.edges()
e1 = []
for f,t in e0:
if (f,t) not in e1 and (t,f) not in e1:
e1.append((f,t))
# Create edges
#for frm, to in set(graph.edges()):
for frm, to in set(e1):
self._draw_edge(frm, to)
Thanks jvahue. I actually have some code to save and restore the view written I can merge back into the project. I'll try to do that this weekend. I'll also look at your other issues.