Assume I have list of tuples edges = [(0,1),(0,3),(0,4),(1,2),(1,3),(1,4),(2,3),(2,4)] and list of lists vertices = [[1,4,2,3,0],[3,0,1,2,4],[2,3,0,1,4],[1,3,2,1,4],[0,3,2,4,1]]. Then I want to check if first and last element of each list in vertices exists in edges then do some stuff.
For example in the first list of vertices which is [1,4,2,3,0], first and last items which are 1 and 0 exits in edges (0,1) (it could be both (0,1) and (1,0)) then do some stuff and same for all list of vertices. I am not sure how to continue the code below.
edges = [(0,1),(0,3),(0,4),(1,2),(1,3),(1,4),(2,3),(2,4)]
vertices = [[1,4,2,3,0],[3,0,1,2,4],[2,3,0,1,4],[1,3,2,1,4],[0,3,2,4,1]]
for i in range(len(vertices)):
if vertices[i][0] and vertices[i][-1] in edges:
do stuff...
Aucun commentaire:
Enregistrer un commentaire