Ask Your Question
1

how do I set label of multiedges graph

asked 2015-01-31 14:01:13 -0500

updated 2015-01-31 16:12:56 -0500

Hello,

Let me consider a graph that I often need to use: the graph with one vertex and three loops.

sage: G = DiGraph([(0,0,'a'), (0,0,'b'), (0,0,'c')])

Is there a way to change the labels after the creation? Because

sage: G.set_edge_label(0,0,'d')
Traceback (most recent call last):
...
RuntimeError: Cannot set edge label, since there are multiple edges from 0 to 0.

Vincent

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2015-01-31 15:20:30 -0500

tmonteil gravatar image

Of course you would have to specify which label will be replaced by 'd'. I did not found such a method in Sage (and unfortunately the .set_edge_label() method does not offer the possibility to specify which edge you would like to relabel), but you can always fallback to:

sage: G.edges()
[(0, 0, 'a'), (0, 0, 'b'), (0, 0, 'c')]
sage: G.delete_edge((0,0,'b'))
sage: G.add_edge((0,0,'d'))
sage: G.edges()
[(0, 0, 'a'), (0, 0, 'c'), (0, 0, 'd')]
edit flag offensive delete link more

Comments

Ptin mais vous vous creez du Karma entre vous maintenant ? :-PPP

Nathann gravatar imageNathann ( 2015-01-31 17:13:31 -0500 )edit

@Nathann J'espere que tu as vote pour nous :-D

vdelecroix gravatar imagevdelecroix ( 2015-01-31 17:42:31 -0500 )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: 2015-01-31 14:01:13 -0500

Seen: 136 times

Last updated: Jan 31 '15