Ask Your Question
0

Changing display labels of nodes on a graph

asked 2020-04-15 09:33:36 +0100

oldani gravatar image

updated 2020-06-09 11:28:40 +0100

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

edit retag flag offensive close merge delete

Comments

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

slelievre gravatar imageslelievre ( 2020-04-16 00:09:09 +0100 )edit

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 ( 2020-04-16 15:24:20 +0100 )edit

The structure and meaning of your last sentence escape me.

slelievre gravatar imageslelievre ( 2020-04-16 17:50:05 +0100 )edit

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 ( 2020-04-16 23:54:13 +0100 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2020-04-16 09:40:16 +0100

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").

edit flag offensive delete link more

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 ( 2020-04-16 15:10:43 +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

1 follower

Stats

Asked: 2020-04-15 09:33:36 +0100

Seen: 665 times

Last updated: Apr 16 '20