Ask Your Question
0

getting edge labels in a digraph to display properly

asked 12 years ago

anonymous user

Anonymous

updated 12 years ago

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.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 12 years ago

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.

Preview: (hide)
link

Comments

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

kcrisman gravatar imagekcrisman ( 10 years ago )

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: 12 years ago

Seen: 2,093 times

Last updated: Aug 19 '12