Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. def path_to_friend(network, user_A,user_B, path=None, variable=None):
  2. if user_A not in network or user_B not in network:
  3. return None
  4. if path == None:
  5. path=[user_A]
  6. if user_B in network[user_A][0] or user_B==user_A:
  7. path=path+[user_B]
  8. return path
  9. for i in network[user_A][0]:
  10. variable=path_to_friend(network,i,user_B,path)
  11. if i not in path and variable:
  12. path=path+[i]
  13. return variable
  14. return None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement