Ask Your Question
2

how do I set label of multiedges graph

asked 2015-01-31 21:01:13 +0200

vdelecroix gravatar image

updated 2015-01-31 23:12:56 +0200

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
3

answered 2015-01-31 22:20:30 +0200

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-02-01 00:13:31 +0200 )edit

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

vdelecroix gravatar imagevdelecroix ( 2015-02-01 00:42:31 +0200 )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 21:01:13 +0200

Seen: 1,087 times

Last updated: Jan 31 '15