Advertisement
davegimo

grafi

Mar 6th, 2021
912
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. def ric(g,u,lista,visited):
  2.     i = u.getId()
  3.     visited.append(i)
  4.    
  5.     if int(i) % 2 == 1:
  6.         lista.append(i)
  7.  
  8.     connections = u.getConnections()
  9.    
  10.     if connections == []: #passo base
  11.         return
  12.  
  13.     else:
  14.         for el in connections:
  15.             if el not in visited:
  16.                 uu = g.getVertex(el)
  17.                 ric(g,uu,lista,visited)
  18.  
  19.    
  20.  
  21.  
  22. def f(g,u):
  23.     lista = []
  24.     visited = []
  25.     ric(g,u,lista,visited)
  26.     return lista
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement