> I want to show a tree with edge labels. I tried out
>
> G1 = Graph({1:{5:0},2:{5:1},3:{6:1},4:{7:0},5:{6:0},6:{7:1}})
> show(G1,edge_labels=true)
> show(G1,layout="tree",edge_labels=true)
>
> In the first graphic the labels are positioned on the edges but in the
> second one they are not. Why is this? How can I get it right?
I think this is related to
http://trac.sagemath.org/sage_trac/ticket/10124, or at least my
patched version seems to work. The basic problem is that
graph_plot.py has problems with integer positions because integer
division is truncating in Python 2 and it's easy to forget to handle
the integer case when your inputs are typically floats. (This problem
goes away in Python 3.)
You could either apply the posted patch, or -- as a hack which doesn't
require any rebuilding -- you could type the following before you plot
G1:
# trac #10124 partial monkeypatch
def set_pos(self):
self._pos = self._graph.layout(**self._options)
self._pos = dict((k,(float(v[0]), float(v[1]))) for k,v in
self._pos.iteritems())
import sage.graphs.graph_plot
sage.graphs.graph_plot.GraphPlot.set_pos = set_pos
which should work around the problem in the meantime, unless this
coffee hasn't kicked in yet..
Doug
--
Department of Earth Sciences
University of Hong Kong
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org