New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor the graph layout code, and add interface with graphviz #7004
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
comment:9
Cc me |
comment:10
I tried reproducing this:
But I got:
Looks like the first if of |
comment:11
I tried this again, and now I am getting a different (!) error:
I'm baffled. |
comment:12
Ooops, sorry Robert for the wasted time, I completely forgot to upload the latest version on trac yesterday night. I also screwed up in my example which too small. Please try instead:
Looking again at those pictures, it feels like the nodes of same height do not repulse each other, or at least not as much as in the pure spring layout. |
This comment has been minimized.
This comment has been minimized.
comment:14
See discussion on http://groups.google.com/group/sage-devel/browse_thread/thread/c46b8a2fcbb5875a |
comment:15
All graphs used to plot as square plots, whether you wanted them to or not. This would stretch any plot into a square, so if the relative distances were larger in one dimension than in the other, this would not show in the plot. The following adjustment seems to improve the situation a bit, but I'm really not sure what the "right" fix is here.
|
comment:16
Hi there, Compiling the doc in our queue if found a missing
Nicolas: please upload or fold in yours at will. |
comment:17
Sorry for replying to myself... Reading the doc I noticed the following: Nicolas you probably want to add yourself in the list of authors to the file |
comment:18
The uploaded patch folds in Florent's doc fix, adds me as author as he suggested, and adds a couple comments here and there. |
This comment has been minimized.
This comment has been minimized.
Reviewer: vdelecroix |
comment:20
It's not clear from the graph documentation that we can use latex for the output. It could be clearer to have a link in the docstring of the plot method or in the one of the object (Graph or DiGraph) itself. An important option that I did not find
It could be nice to have pointers in the documentation:
|
comment:21
The documentation is quite clear and complete but in an "hidden" file: sage.graphs.graph_latex The refactorization of the code is really good, I will just talk about the graphviz, string and latex possibilities. Perhaps for other tickets...
There is different standards format for string representations of graph objects. At least two or three
From now, there exists a method graphviz_string. Could we prefer a dot_string ? and in the same manner think about a graphml_string ?
There is a intersection between the two format of GraphLatex (which is written in the description). dot2tex is able to produce a lot of different format... Couldn't we prefer in the GraphLatex file some different methods
and have an option inside picture_tikz to consider whether we use dot2tex or we use the actual code ?
It took one second to execute in a console
And almost one minute for
Do you have an idea where the time is lost ?
There is a java program which can be used to interact with graphviz: http://www.dynagraph.org/ It is available under the Common Public License |
comment:22
Replying to @videlec:
+1 on adding appropriate links.
:-)
Yup. Note that there already exists methods graph6_string
The ..._string convention is followed consistently; so it might be a
I see all those methods as internal (actually, maybe they should start I would not mind if the latex method would take extra arguments (as a
Ah, interesting! On extra thing that dot2tex does it to run latex on
+1 definitely! It does not seem to have been very active recently though. Cheers, |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
comment:25
Calling view on a graph with dot2tex format can be a bit slow. But see #8707 for making it 5 times faster :-) |
This comment has been minimized.
This comment has been minimized.
Attachment: trac_7004-graphviz.patch.gz Apply only this patch that fold all others |
comment:27
All test pass, documentation builds without warning and we get beautiful graphs! |
Attachment: trac_7004-graphviz-nt.patch.gz Apply only this one |
comment:29
Hi! I made a micro fix in dot2tex_utils.py: the (assert_) have_dot2tex methods are now tested I also made micro changes in the patch header. |
comment:30
Tests still pass and doc still builds. It's OK for me. |
Merged: 4.4.1.alpha2 |
Changed reviewer from vdelecroix to Vincent Delecroix |
Changed merged from 4.4.1.alpha2 to sage-4.4.1.alpha2 |
Latest version of the patch on:
http://combinat.sagemath.org/hgwebdir.cgi/patches/file/tip/trac_7004-graphviz-nt.patch
and followups
Using the graphviz interface requires graphviz to be installed on the
machine, as well as a dot2tex spkg which can be installed with:
From the patch description:
Refactors the graph layout code:
Add a new main graph.layout() method, to be called by plot, plot3d, latex, graph_editor, ...
The various graph layout algorithms spread over the graph code are systematically reorganized into as many layout methods that can be called from layout():
graph.layout_circular()
graph.layout_spring()
graph.layout_tree()
graph.layout_ranked()
graph.layout_acyclic()
graph.layout_planar()
graph.layout_default()
Extends the graphviz_string method (latex labels) and refactors its logic to make it simpler for subclasses
Slightly simplifies the handling of default values for graph.latex_options
Visible user change: graph_editor, plot3d, ... all accept the same layout options.
Implements an interface to dot2tex/graphviz:
Define a new layout method .layout_graphviz() implemented by calling dot2tex and graphviz
Implement an alternative implementation of latex for graphs by delegating all the work to dot2tex (GraphLatex.dot2tex_picture)
Makes some fixes to the poset code:
__repr__
->_repr_
_latex_
by calling latex on the internal elementMoved the level_sets method from HasseDiagram to DirectedGraph Reimplemented to support properly non acyclic graph. It should be quite faster (it just goes through the graph, without modifying it).
TODO, for this ticket or a later one:
Double check all the logic to make sure it is backward compatible
What should be the default layout algorithm?
layout is not that nice looking; postponed for later when
planar+spring will be implemented)
The spring option for ranked layouts does not work nicely:
to be compared with:
Thinking twice about it, this seems to be inherent. See the comments in the code.
Find a better name for acyclic_dummy. Once the spring layout will be functional, this could be set to the default value, and the layout renamed to acyclic_spring.
Choose a good option name for the direction of growth of acyclic layout, an a good default value. Merge this with the option for tree layout (tree_orientation).
A lot of code is doing things very similar to dot2tex. Maybe things could be merged.
Implement the various options for both latex constructions (tikz or dot2tex)
Implement the default layout of standard graphs using a default_layout method rather than at construction time.
CC: @sagetrac-sage-combinat @nathanncohen @rlmill
Component: graph theory
Keywords: graph layout, graphviz, acyclic
Author: Nicolas M. Thiéry
Reviewer: Vincent Delecroix
Merged: sage-4.4.1.alpha2
Issue created by migration from https://trac.sagemath.org/ticket/7004
The text was updated successfully, but these errors were encountered: