Advertisement
Guest User

Asd-Esercizio3-giugno2017-traccia2

a guest
Nov 14th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. Algo(G,a,b,c)
  2.  
  3. INIT(G)
  4. c[c]=n
  5. ret=false
  6. dfs_visit(G,a) // normale dfs visit
  7. if(c[b]=n)then
  8. INIT(G)
  9. c[a]=n
  10. dfs_visit(G,b) // normale dfs visit
  11. if(c[c]=n)then
  12. INIT(G)
  13. ret=dfs_visitmod(G,c)
  14. return ret
  15.  
  16. dfs_visitmod(G,s)
  17.  
  18. c[s]=g
  19. ret=false
  20. for each v in Adj[s]do
  21. if c[v]=b then
  22. ret=dfs_visitmod(G,v)
  23. if ret=false then
  24. return false
  25. else if c[v]=g then
  26. if v=a or v=b or v=c then
  27. ret=false
  28. else
  29. ret=true
  30. c[s]=n
  31. return ret
  32.  
  33.  
  34.  
  35. INIT(G)
  36. for each v in V do
  37. c[v]=b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement