[sage-support] Re: drawing graphs
Here, for example, is the Cayley graph of the alternating group A5: A = AlternatingGroup(5) G = Graph(A.cayley_graph()) s = G.graphviz_string() f = open('graphfile.dot', 'w') f.write(s) f.close() Actually for this example graphviz's neato (i.e. spring model) doesn't do much better than SAGE's spring. What Sage seems to be missing completely is the functionality of dot, which is for acyclic directed graphs, but works with all graphs (i.e. acyclicity is not enforced). SAGE has a tree layout but it is enforced the graph to be a tree (unless I am overlooking something there is no user way around it). However, imagine a graph that is a huge tree with only one cycle. Such graph will benefit more from a tree layout that spring (just by ignoring the extra edge and adding it at the end). According to the manual of graphviz dot implements this paper (so it might be worth looking at): Emden R. Gansner, Eleftherios Koutsofios, Stephen C. North, and Kiem- Phong Vo. A Technique for Drawing Directed Graphs. IEEE Trans. Sofware Eng., 19(3):214–230, May 1993. PS. to see the pictures use the code above in sage and then {dot, neato or dfp} -Tpng graphfile.dot graph.png, assuming you have graphviz installed. --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: drawing graphs
On Jun 16, 2:36 am, Rado rki...@gmail.com wrote: Here, for example, is the Cayley graph of the alternating group A5: A = AlternatingGroup(5) G = Graph(A.cayley_graph()) s = G.graphviz_string() f = open('graphfile.dot', 'w') f.write(s) f.close() Actually for this example graphviz's neato (i.e. spring model) doesn't do much better than SAGE's spring. What Sage seems to be missing completely is the functionality of dot, which is for acyclic directed graphs, but works with all graphs (i.e. acyclicity is not enforced). Yes, I think I agree. Before posting, I checked this on my laptop, which has the old Pixelglow version of Graphviz on it. The result looks vastly superior to Sage's and appears to be layed out in the hierarchical fashion specified by dot. Although, I did nothing to request that layout format. Mark --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: drawing graphs
Please -- Emily and Robert -- don't be at all offended by this email. You two have both dramatically improved graph plotting in Sage over what networkx offers, and Emily's predesigned layouts for the graph families are beautiful. I just think it is important to acknowledge that on random input graphs plotting has a ways to go. I'm forwarding what Emily has to say about this, since she's very busy at the moment. Also, I'd like to point out that there are yearly conferences all over the world about graph layout, so it's not exactly a solved problem. That said, many of the issues with Sage drawing graphs are much more basic than the things discussed at these conferences... There are a bunch of things I am still messing with on graph plotting and the cutting off of vertices is a priority. It's actually a problem with scatterplots in general that Robert, Mike Hanson and I were talking about at the last Sage Days. Basically, scatterplots set point size as points^2, so there's no way to get the radius of the point in xy-data. Without knowing the radius of the points, the canvas ends up being trimmed too much and cutting off part of the points. Mike was working on plot.py and changing the way canvases are collecting data and drawn. Meanwhile, I think graphs should step away from using scatterplot anyway. There are longterm benefits for this-- one is that eventually we can use matplotolib's patch collection and allow patch-joining, which should significantly cut down on our computations for digraphs with arced edges. The immediate benefit is that it will get rid of the vertex cut-off problem independent of improvements to scatterplot. For example, try plotting small multi-edged digraphs and see that the vertices are never cut off. Those draw a collection of circles instead of a scatterplot, because we need to know the radius to draw the arrow in the right spot. One immediate loss is that we will be back to only allowing circle representation for vertices (currently the scatterplot allows squares, triangles, stars, etc.) but that is something that can be added later on top of a better implementation. Another consideration is timing, but this is something that can also be improved upon in the future (possibly by wrapping/enabling matplotlib's patchcollection). --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: drawing graphs
On Mon, Jun 15, 2009 at 12:55 PM, Dominique Manchonmanc...@math.univ-bpclermont.fr wrote: Hello! I'm a newcomer into Sage and Python. When I want to draw some graphical representation of graphs I get problems : the vertices are partially cut-off. They almost disappear when the graph looks like a vertical ladder. For example: Despite years of work, drawing graphs in Sage is still pretty broken. This is very clear to anybody who uses the Sage graph code for any amount of time. The graph plotting works well for: * circular planar graphs * all the graphs you get by typing graphs.tab key (thanks Emily) * sometimes for connected graphs. It's *terrible* for graphs with multiple components. And for random small graphs, as you say it chops off vertices, and generally looks very unpolished. My understanding is that the following work has been done on graph plotting in Sage: * take the networkx graph plotting code and make it actually work from sage * nice layouts for everything in graphs.tab key * make it so the spring layout algorithm runs very very quickly * add support for loops and multiple edges (thanks emily) * add a layout=circular algorithm * add a layout=tree algorithm * lots of support for colorings (in sage-4.0.1) It's pretty clear substantial further work is still needed. I taught an undergrad course last quarter using Sage, and found plotting with anything but layout=circular to be sort of embarrassing. But I didn't do anything about it. Please -- Emily and Robert -- don't be at all offended by this email. You two have both dramatically improved graph plotting in Sage over what networkx offers, and Emily's predesigned layouts for the graph families are beautiful.I just think it is important to acknowledge that on random input graphs plotting has a ways to go. -- William arbre1={0:[1],1:[]} arbre2={0:[1,2],1:[],2:[]} A1=Graph(arbre1) AA1=A1.plot(vertex_size=120, layout=tree, tree_orientation=up,tree_root=0) A2=Graph(arbre2) AA2=A2.plot(vertex_size=120, layout=tree, tree_orientation=up,tree_root=0) AA1.show(figsize=[2,2]);AA2.show(figsize=[2,2]) How can I cure this? Another related question : which values are allowed for figsize[-,-]? Very often I would like quite tiny drawings (hence small values) but then I get an error message. For example the same as above with figsize=[1,1] returns the message below. Why? Thanks in advance for the help. Dominique Manchon libpng error: Image width or height is zero in IHDR Traceback (most recent call last): File stdin, line 1, in module File /home/sage/sagenb/sage_notebook/worksheets/manchon/4/code/ 24.py, line 13, in module AA1.show(figsize=[_sage_const_1 ,_sage_const_1 ]);AA2.show(figsize=[_sage_const_1 ,_sage_const_1 ]) File /home/sage/sage_install/sage/local/lib/python2.5/site-packages/ Jinja-1.2-py2.5-linux-x86_64.egg/, line 1, in module File /home/sage/sage_install/sage/local/lib/python2.5/site-packages/sage/ plot/plot.py, line 1291, in show hgridlinesstyle=hgridlinesstyle) File /home/sage/sage_install/sage/local/lib/python2.5/site-packages/sage/ plot/plot.py, line 1616, in save canvas.print_figure(filename, dpi=dpi) File /home/sage/sage_install/sage/local/lib/python2.5/site-packages/ matplotlib/backend_bases.py, line 1453, in print_figure **kwargs) File /home/sage/sage_install/sage/local/lib/python2.5/site-packages/ matplotlib/backends/backend_agg.py, line 334, in print_png filename_or_obj, self.figure.dpi) RuntimeError: Error building image -- William Stein Associate Professor of Mathematics University of Washington http://wstein.org --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: drawing graphs
On Jun 15, 10:38 am, William Stein wst...@gmail.com wrote: On Mon, Jun 15, 2009 at 12:55 PM, Dominique Manchonmanc...@math.univ-bpclermont.fr wrote: Hello! I'm a newcomer into Sage and Python. When I want to draw some graphical representation of graphs I get problems Despite years of work, drawing graphs in Sage is still pretty broken. Graph drawing works well enough for me, when I just want a quick idea of what's going on. If I need a well drawn graph, I just export to Graphviz. Graphviz is open source but I seem to recall that its license is not Sage compatible. It is, nonetheless, freely available. Here, for example, is the Cayley graph of the alternating group A5: A = AlternatingGroup(5) G = Graph(A.cayley_graph()) s = G.graphviz_string() f = open('graphfile.dot', 'w') f.write(s) f.close() If you now open graphfile.dot in Graphviz, you should get a an interpretable version of quite a complicated graph. Mark McClure --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: drawing graphs
On Tue, Jun 16, 2009 at 12:27 AM, mark mccluremcmcc...@unca.edu wrote: On Jun 15, 10:38 am, William Stein wst...@gmail.com wrote: On Mon, Jun 15, 2009 at 12:55 PM, Dominique Manchonmanc...@math.univ-bpclermont.fr wrote: Hello! I'm a newcomer into Sage and Python. When I want to draw some graphical representation of graphs I get problems Despite years of work, drawing graphs in Sage is still pretty broken. Graph drawing works well enough for me, when I just want a quick idea of what's going on. If I need a well drawn graph, I just export to Graphviz. Graphviz is open source but I seem to recall that its license is not Sage compatible. It is, nonetheless, freely available. True, but I will be happier when Sage's graph drawing is at least as good as Graphviz's. Who amongst you is up to the challenge? Here, for example, is the Cayley graph of the alternating group A5: A = AlternatingGroup(5) G = Graph(A.cayley_graph()) s = G.graphviz_string() f = open('graphfile.dot', 'w') f.write(s) f.close() If you now open graphfile.dot in Graphviz, you should get a an interpretable version of quite a complicated graph. University of Washington http://wstein.org --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Drawing graphs with color coded edge labels
Hi, sorry for the late reply -- it's final's week. William Stein [EMAIL PROTECTED] writes: On Sat, May 17, 2008 at 2:26 PM, Nikos Apostolakis [EMAIL PROTECTED] wrote: And a more general question. I generated this graph as follows: I have a group G with two generators acting on a finite set X. I use GAP to get the orbits of each generator and then I write a smal script to produce a SAGE DiGraph from these data: vertices correspond to elements of X and edges correspond to the generators of G. Is there a more straightforward way to do this in SAGE, I mean starting from a group action to get a digraph? I don't think there is. Improving Sage so that there *is* a straightforward way to do this would be a great contribution for somebody to make to Sage! I guess one would need to start by implementing group actions in Sage, at the moment they are not implementedl, right? Nikos --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Drawing graphs with color coded edge labels
Nikos Apostolakis [EMAIL PROTECTED] writes: Hello, I have a directed graph with edges labeled using two different labels. Is it possible to draw this graph (2D or 3D) using two different colors to signify the different labels, eg red for one label and green for the other? I seem to remember seeing such an exmple somewhere but I wasn't able to find it again. Sorry for answering my own question. The option I was looking for was color_by_label = True in plot3d. Nikos --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Drawing graphs with color coded edge labels
On Sat, May 17, 2008 at 2:26 PM, Nikos Apostolakis [EMAIL PROTECTED] wrote: Hello, I have a directed graph with edges labeled using two different labels. Is it possible to draw this graph (2D or 3D) using two different colors to signify the different labels, eg red for one label and green for the other? I seem to remember seeing such an exmple somewhere but I wasn't able to find it again. And a more general question. I generated this graph as follows: I have a group G with two generators acting on a finite set X. I use GAP to get the orbits of each generator and then I write a smal script to produce a SAGE DiGraph from these data: vertices correspond to elements of X and edges correspond to the generators of G. Is there a more straightforward way to do this in SAGE, I mean starting from a group action to get a digraph? I don't think there is. Improving Sage so that there *is* a straightforward way to do this would be a great contribution for somebody to make to Sage! William --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---