Advertisement
luca_mazz1

[ASD] SOLUZIONE SERGIO MAURO 06/17

Jan 22nd, 2019
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. ALGO(G,a,b,c,d)
  2. INIT(G)
  3. DFS_visit(G,a) //classica DFS
  4. if col[b]=n then
  5. if isCiclico(G,b) then
  6. INIT(G)
  7. col[c]=col[d]=n
  8. DFS_visit(G,a)
  9. if col[b]=n then
  10. return false
  11. return true
  12.  
  13. isCiclico(G,v)
  14. INIT(G)
  15. return !DFS_visit_mod(G,v)
  16.  
  17. DFS_visit_mod(G, v)
  18. col[v]=g
  19. for each u€Adj[v] do
  20. if col[u]=b then
  21. return DFS_visit_mod(G,u)
  22. else if col[u]=g then
  23. return false
  24. col[v]=n
  25. return true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement