Advertisement
Davencode

Untitled

Jul 3rd, 2021
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. Algo(G,B)
  2. INIT(G)
  3. L=Nil
  4. DFS_VISIT(G,s,c,B,L)
  5. for each x in L do
  6. DFS_VISIT(L,x,c1)
  7.  
  8. INIT(G)
  9. for each v € V do
  10. c[v]=bianco
  11. c1[v]=bianco
  12.  
  13. DFS_VISIT(G,s,c,B,L)
  14. c[s]=grigio
  15. trovato=true
  16. for each u € adj[s] do //ITERO GLI ADIACENTI DI S
  17. if (c[u]=bianco) then //Se l'adiacente è bianco
  18. DFS_VISIT(G,u,c,B) //richiamo di nuovo DFS_VISIT e visito il successivo
  19. else if(c[u]=grigio) then //Se è grigio l'elemento adiacente e quindi se è un percorso infinito
  20. if (c[u] IN B) then //controllo se è contenuto in B tale elemento adiacente
  21. trovato=true //se lo è abbiamo trovato l'elemento B che è appartenente a un percorso infinito (occorre tante
  22. volte)
  23. L=add(L,u)
  24. else
  25. trovato=false
  26. c[s]=nero
  27.  
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement