Advertisement
Davencode

Untitled

Jul 2nd, 2021
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. Algo (G,a,b,c,d)
  2. Init(G) //inizializzare grafo
  3. c[c]= nero
  4. c[d]= nero
  5. DFS(G,a,c) // inizializzo la DFS partendo da a assumento colore c che in init sarà bianco
  6. for each v in V do
  7. if [c[d]=b] then // qui verifico se il vertice di arrivo d è bianco vuol dire che ci sarà stato qualche
  8. nodo nero che ha intralciato il grafo e quindi che è uno che abbia c,d
  9. return true
  10. else
  11. return false
  12.  
  13.  
  14. DFS(G,s,c)
  15. c[s] = grigio
  16. for each v in adj[v] do
  17. if [c[v] = bianco] then
  18. DFS(G,s,c)
  19. c[s]= nero
  20.  
  21. INIT(G)
  22. for each v in V do
  23. c[v] = bianco
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement