Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Algo072016(G,u,z,v,k)
- Init(G)
- colore[v]=rosso
- distv=BFS(G,z)
- if(distv[v]!=nil)
- return false
- Init(G)
- T=Trasposta(G)
- colore[u]=rosso
- distu=BFS(T,z)
- if(distu[u]!=nil)
- return false
- if((distv[v]+distu[u])>K)
- return True
- return False
- BFS(G,s)
- colore[s]=grigio
- coda={s}
- dist[s]=0
- While(coda)
- u=testa(coda)
- for each v Adj u do
- if(colore[v]=bianco)
- colore[v]=grigio
- dist[v]=dist[u]+1
- accoda(coda,v)
- else
- if(colore[v]=rosso)
- dist[v]=dist[u]+1
- decoda(coda)
- colore[u]=nero
- return dist
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement