NEWER: graphs on a canvas in leo

So rather than use the easy API and pretty anti-aliasing of gnomecanvas I found Gred.py, a graph editor in tkinter in the Gato package: http://gato.sf.net/ It's already done most of the work and tkinter avoids issues with Windows portability.

Given a Leo representation of a graph like this:

lg0-0.png

You can load and arrange it in the graph editor like this:

lg0-1.png

Then play with it, reversing some links (the red is not part of the graph) and adding some nodes:

lg0-2.png

And you get back something like this:

lg0-3.png

the 'save graph to leo' algorithm decides to use child2 as a top level node this time because it has more children than the old "root node".

Now (20071001) I just need to save the x,y positions of the nodes as uAs, which should be easy, and resolve some tkinter stuff about opening and closing top level windows, which would probably also be easy, if I had any idea what I was doing.

NEW: graphs on a canvas

Here's a screen shot from a network editor I just (20070905) threw together using pyGTK and gnomecanvas. Nodes can be dragged around, taking their links with them, the links are also sensitive to editing clicks.

roadnet.png

Making this was very easy, and makes me think that a canvas based graph editor for leo shouldn't be impossible. It seems right now that the python gui world is lacking a clear leader for a canvas widget. gnomecanvas was used here, seems ok, but not available (without effort) for windows. hippocanvas is also GTK compatible, and is being used by the One Laptop Per Child (OLPC) initiative, so it may have ongoing potential. There's also a goocanvas in the GTK realm. There are a couple of different choices in the Wx world that I haven't really played with, one with doubtful maintenance, and the other needing extra pieces.

So no clear choice for a canvas widget, but as long as you have something at least as good as gnomecanvas, editing networks this way in python doesn't seem difficult. There are other more graph aware options like python bindings for Dia canvas, but the code for the above was so simple it seems the advantages of rolling your own might be worthwhile here.

Older notes

There's been a lot of talk about Leo handling graphs of node, i.e. networks of nodes where any node can be connected to any other and loops are possible, rather than just a tree of nodes. Clones provide some of this functionality, but not the full freedom of an arbitrary graph.

To experiment with the idea of navigating a graph using a tree I've made a small wxPython app. Copy

treenet.py

and

treenet_ui.py

to the same directory and run treenet.py.

The graph that you're navigating starts off looking like this:

treenet.png treenetss.png

The point of this demo is that in the tree view, starting from say Cinnamon, you can select Toast, Foods, Spam, Red... which brings you back to Cinnamon, several layers into the tree instead of at the root. This can go on forever, but of course there's no reason the user would do that, and you can set a new root anytime with the 'Start from node' button.

You can mark a node and the select a different node and link or unlink them. Links are non-directional, and you can have more than one link between the same two nodes.

I hope this toy might be useful while people are thinking about what it means to navigate a graph in a tree view, but I hope that soon Leo will start to do that itself, so I don't see any future development of this toy. In a real world application I think links would need to be directional, and it would probably be useful if they carried attributes as well. Then of course there's the issue of how this translates into Leo's vnode / tnode view - not wanting to touch that was what prompted me to make this program.

Updating of the display when there are multiple links between the same pair of nodes doesn't work that well, but it's just an experiment, not meant for use.