Advertisement
Giuliox

28/06/2017 Traccia 1 Esercizio 3

Jan 16th, 2018
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. Algo(G,a,b,c,d)
  2. Init(G)
  3. state = 0, foundB = False
  4. for each v € Adj(a):
  5. if not DFSmod(G,v,b,c,d,state,foundB)
  6. return False
  7. return True
  8.  
  9. DFSmod(G,v,b,c,d,state,foundB)
  10. col[v]=g
  11. if (v = c or v = d) and not foundB:
  12. state++
  13. else if v=b:
  14. foundB=True
  15. for each u € Adj(v):
  16. if col[u]=g:
  17. if foundB and state != 2:
  18. return False
  19. else if col[u]=b:
  20. if not DFSmod(G,u,b,c,d,state,foundB)
  21. return False
  22. col[v]=n
  23. return True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement