# getting edge labels in a digraph to display properly

Anonymous

I am new to Sage, and I am trying to get the program to display labeled digraphs the way that I want them. I give Sage the code:

sage: g = DiGraph({0:{1:'x',2:'z',3:'a'}, 2:{5:'out'}});
sage: g.show(edge_labels=True)


When I do this, the graph is displayed with the edge labels, but the labels appear right on top of the edges, which makes the labels hard to read. How do I get the program to display the edge labels right next to the edge, rather than on them? Any help will be appreciated.

edit retag close merge delete

Sort by » oldest newest most voted

I'm not an expert in the graph theory portion of Sage, but here is what I've found. The position of the label appears to be hard-coded in as the midpoint between the vertices, which is what you want to change. If you look at the answer to Font Size for Edge Label, you'll see there is a line of code that includes a text command. The first argument of the text command is the text to be displayed (the edge label in this case) and the second argument is the position. You'll see the position is programmed to be the midpoint of the edge. You could modify this position to move the label away from the edge.

I realize this is not a pretty solution. Perhaps someone will suggest something simpler.

more

Something like this is now http://trac.sagemath.org/ticket/16450

( 2014-06-05 23:35:51 +0200 )edit

## Stats

Seen: 952 times

Last updated: Aug 19 '12