Davencode

Untitled

Jul 3rd, 2021 (edited)
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. Algo(G,s,u,VAL[])
  2. INIT(G)
  3. L1=NIL
  4. L2=NIL
  5. DFS_VISIT(G,s,c) //effettuo una comune DFS_VISIT
  6. DFS_VISITPARI(G,s,c2,i,L1)
  7. DFS_VISITDISPARI(G,s,c3,i,L2)
  8. --------------------------------
  9. //La DFS che effettuo s'incentra sul visitare comunemente i vertici poi nel caso becca una condizione
  10. di percorso infinito verifico oltre a quella condizione se quel c[u] adiacente è proprio u e in tal caso
  11. ritorno true e dovrei riuscire nel primo punto
  12. DFS_VISIT(G,s,c)
  13. c[s]=grigio
  14. for each u € adj[s] do
  15. if(c[u]=bianco)then
  16. DFS_VISIT(G,u,c)
  17. else if(c[u]=grigio && c[u]=u)then
  18. return true
  19. else
  20. return false
  21. c[s]=nero
  22. --------------------------------
  23. //DFS_VISITPARI(G,s,c2,i,L1)
  24. c[s]=grigio
  25. for each u € adj[s] do
  26. if(c[u]=bianco)then
  27. DFS_VISITPARI(G,u,c2,i+1)
  28. else if(c[u]=grigio)then
  29. if(i%2=0)then
  30. L1=ADD(L1,u)
  31. c[s]=nero
  32. --------------------------------
  33. //DFS_VISITDISPARI(G,s,c3,i,L2)
  34. c[s]=grigio
  35. for each u € adj[s] do
  36. if(c[u]=bianco)then
  37. DFS_VISITDISPARI(G,u,c3,i+1)
  38. else if(c[u]=grigio)then
  39. if !(i%2=0) then
  40. L2=ADD(L2,u)
  41. c[s]=nero
Add Comment
Please, Sign In to add comment