wting / python-graph

Automatically exported from code.google.com/p/python-graph
Other
5 stars 4 forks source link

Add Pygame output #63

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
An awesome feature would be nice if library could calculate optimal 
coordinates of nodes and paths to be displayed in 2D canvas of Pygame or 
other libraries, i.e. exported to SVG etc.

Original issue reported on code.google.com by techtonik@gmail.com on 5 Jan 2010 at 11:48

GoogleCodeExporter commented 9 years ago
The dot program takes a graph in the dot language and spits it out in exactly 
what
you're after -- optimal coordinates based on the graph layout you've chosen. You
should fire up a text editor, and take a gander at what the output is. For more 
info
you can check the man-page for dot and look under the section 'OUTPUT FORMATS'.

  Let me know if this solves your problem and I'll mark this issue as invalid.

Original comment by christian.muise on 5 Jan 2010 at 4:35

GoogleCodeExporter commented 9 years ago
No. I want clear Python solution for the graph. =)

Original comment by techtonik@gmail.com on 5 Jan 2010 at 5:19

GoogleCodeExporter commented 9 years ago
So an export to svg isn't enough?

  If it's an interface that controls a pygame interaction, then I would suspect
that's more of an application / use of pygraph (as supposed to something that 
belongs
in its api). We were considering collecting the applications that use pygraph 
in some
place though, and this may be perfect for that.

Original comment by christian.muise on 7 Jan 2010 at 3:46

GoogleCodeExporter commented 9 years ago
@techtonik: you can export the graph to DOT format and use graphviz to draw it, 
like
we do in the example. Then, you could use pygame to show the image on screen.

http://code.google.com/p/python-graph/wiki/Example

As Christian said, your idea is in the application domain and it doesn't really 
fit
into the library model. If you develop it, let us know so we can link to your 
project.

I'm closing this issue as Invalid, but feel free to comment here if you still 
want to
add something.

Original comment by pmatiello on 7 Jan 2010 at 5:05

GoogleCodeExporter commented 9 years ago
Pygame draws images itself, but it need information where to draw primitives on 
canvas. 
It can then visualize them, add events, animate, but it needs layout 
capabilities of 
either Graphviz of python-graph.

If I understood correctly from above reaction, python-graph is useless without 
Graphviz 
if need to get some useful output out of some useful graph.

Original comment by techtonik@gmail.com on 7 Jan 2010 at 5:47

GoogleCodeExporter commented 9 years ago
Answering christian.muise:
> So an export to svg isn't enough?

It would help a lot, but I can't find any python-graph examples even for that. 
I would 
like to get a solution in pure Python - if not directly usable with Pygame then 
at 
least with ability to use it in site script without shell access.

Original comment by techtonik@gmail.com on 7 Jan 2010 at 5:52

GoogleCodeExporter commented 9 years ago
  So the actual technology you're after is referred to as 'graph drawing'. It's quite
a large area of research, but unfortunately way out of the scope of 
python-graph. The
lib is meant to deal more-so with the abstract mathematics perspective of graph
theory (we don't typically refer to it as such, but it's pretty much a form of 
set
theory).

  The workaround suggested is to use an off-the-shelf program that specializes in
graph drawing (i.e. graphiz). Yes, it's a command line tool, but there is 
already a
python effort to capture it's features:

- pygraphiz: http://networkx.lanl.gov/pygraphviz/
- docs on layout: 
http://networkx.lanl.gov/pygraphviz/tutorial.html#layout-and-drawing

  Hope this helps. Cheers

Original comment by christian.muise on 7 Jan 2010 at 6:32

GoogleCodeExporter commented 9 years ago
pygraphviz won't install on my windows system. Anyway, seems like it's yet 
another 
wrapper for Graphviz. I dug a bit, but haven't found any python libraries for 
drawing 
graphs without Graphviz.

Handling graph layout calculations (even multipass with incremental 
optimizations via 
feedback) could be an awesome addition to python-graph math. 

There are some pieces of code that may serve as starting points for somebody 
who face 
the same problem:
http://trac-hacks.org/wiki/RevtreePlugin    - SVG Graph draw (pure python)
http://www.onnerby.se/~daniel/dbdesigner/   - Graph layout algorithm in Flash

Original comment by techtonik@gmail.com on 8 Jan 2010 at 9:28

GoogleCodeExporter commented 9 years ago
Did you check out the networkx stuff for drawing? Seems like they've already 
got a
jump on the math you're looking for:
- http://networkx.lanl.gov/reference/drawing.html

  Cheers

Original comment by christian.muise on 11 Jan 2010 at 4:46

GoogleCodeExporter commented 9 years ago
Even though matplotlib license is a mystery to me, the networkx stuff seems to 
be just 
what I need. =) Thanks for the link.

Original comment by techtonik@gmail.com on 11 Jan 2010 at 9:03

GoogleCodeExporter commented 9 years ago
I think it's BSD, no? 
http://networkx.lanl.gov/reference/legal.html?highlight=license

  No worries for the tip, and good-luck with the graph layout.

Original comment by christian.muise on 11 Jan 2010 at 9:08