Advertisement
Guest User

coucou

a guest
Apr 25th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. G1 = {1:[10], 2:[8], 3:[8], 4:[1,2,6], 5:[3,10], 6:[5,7,10], 7:[2,4,5], 8:[5,7], 9:[1,4], 10:[4,9]}
  2. G2 = {}
  3.  
  4. def parcoursLargeur(G,S):
  5. sommetsVisite=[]
  6. estVisite={x:false for x in G}
  7. arboresence={x:x for x in G}
  8. def parcoursSommet(s):
  9. sommetsVisite.append(s)
  10. estVisite[s] = true
  11. for x in G[s]:
  12. if not estVisite[x]:
  13. parcoursSommet(x)
  14. arboresence[x] = s
  15. parcoursSommet(S)
  16. return sommetsVisite,arboresence
  17.  
  18. show (parcoursLargeur(G1,3))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement