First time here? Check out the FAQ!

Ask Your Question
0

Changing display labels of nodes on a graph

asked 4 years ago

oldani gravatar image

updated 4 years ago

FrédéricC gravatar image

Hi, I have created a graph which is in fact a tree. Each node has a label that I gave at creation time. Now, when I plot the graph for each node this "internal" label is displayed. Is it possible to have different display labels than this "internal" label?

Thanks

Preview: (hide)

Comments

Can you provide a small example to illustrate what you have and what you want in a simple case?

slelievre gravatar imageslelievre ( 4 years ago )

The idea is the following. Let's imagine I have defined the graph : G2 = Graph([('a', 'b', 'edge label')]). Like that it is displayed with node labels 'a' et 'b'.

But I want to display G2 (as it is defined) but as G3 = Graph([('Good', 'Morning')]) will be displayed

oldani gravatar imageoldani ( 4 years ago )

The structure and meaning of your last sentence escape me.

slelievre gravatar imageslelievre ( 4 years ago )

Mmmh sorry for my bad english. I found finally another way to solve my problem, I think there was no solution to what I wanted to do. Thanks a lot for your time.

oldani gravatar imageoldani ( 4 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 4 years ago

Sébastien gravatar image

One possibility is that you are specifying the edge labels, not the vertex labels:

sage: G = Graph([('a', 'b', 'edge label')])
sage: G.plot(edge_labels=True)

image description

Since edge labels are not shown by default, what you see in G.plot() are the vertex labels only (that you call "internal").

Preview: (hide)
link

Comments

Oh! yes good idea, if I remove the node labels and keep only edge labels can be a way to go. Thanks

oldani gravatar imageoldani ( 4 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

1 follower

Stats

Asked: 4 years ago

Seen: 755 times

Last updated: Apr 16 '20