Ask Your Question
0

getting edge labels in a digraph to display properly

asked 2012-08-19 15:27:24 +0100

anonymous user

Anonymous

updated 2012-08-19 19:36:41 +0100

Shashank gravatar image

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2012-08-19 21:33:36 +0100

calc314 gravatar image

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.

edit flag offensive delete link more

Comments

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

kcrisman gravatar imagekcrisman ( 2014-06-05 23:35:51 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-08-19 15:27:24 +0100

Seen: 2,000 times

Last updated: Aug 19 '12