Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Algo(G,B)
- INIT(G)
- L=Nil
- DFS_VISIT(G,s,c,B,L)
- for each x in L do
- DFS_VISIT(L,x,c1)
- INIT(G)
- for each v € V do
- c[v]=bianco
- c1[v]=bianco
- DFS_VISIT(G,s,c,B,L)
- c[s]=grigio
- trovato=true
- for each u € adj[s] do //ITERO GLI ADIACENTI DI S
- if (c[u]=bianco) then //Se l'adiacente è bianco
- DFS_VISIT(G,u,c,B) //richiamo di nuovo DFS_VISIT e visito il successivo
- else if(c[u]=grigio) then //Se è grigio l'elemento adiacente e quindi se è un percorso infinito
- if (c[u] IN B) then //controllo se è contenuto in B tale elemento adiacente
- trovato=true //se lo è abbiamo trovato l'elemento B che è appartenente a un percorso infinito (occorre tante
- volte)
- L=add(L,u)
- else
- trovato=false
- c[s]=nero
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement