Find an edge in an undirected graph given two edges

15 views
Skip to first unread message

David Einstein

unread,
Oct 18, 2018, 9:35:43 AM10/18/18
to sage-support
Given an undirected graph g, and two vertices v1 and v2 such that there is an edge connecting them, is there a simple way to figure out which one of (v1, v2) or (v2, v1) will be the edge that occurs in g.edges(labels=False)?


Jakub Sliacan

unread,
Oct 18, 2018, 9:43:34 AM10/18/18
to sage-support
I thought edges are always listed sorted, i.e. x <= y in (x,y). Can you produce an example when this is not the case?

David Einstein

unread,
Oct 18, 2018, 9:46:44 AM10/18/18
to sage-support
No, I cannot, but as we transfer to Python 3 it is no longer guaranteed that vertices will be sortable, and so tuple(sorted([v1,v2])) should be avoided.  
Reply all
Reply to author
Forward
0 new messages