SHARE
TWEET

Esercizio 3 19/02/2019

a guest Jun 25th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Algo(G,k,s,A)
  2.   init(G,A);
  3.   ret=BFS_VisitMod(G,s,k)
  4.   return ret;
  5.  
  6.  
  7. init(G,A)
  8.   for each v in V do
  9.     color[v]=bianco;
  10.   for each v in A do
  11.     color[v]=rosso;
  12.  
  13. BFS_VisitMod(G,s,k)
  14.   dist[s]=0;
  15.   color[s]=grigio;
  16.   Q={s};
  17.   while(Q!=NULL)do
  18.     u=Testa(Q);
  19.     for each v in adj(u) do
  20.       if(color[v]=bianco || color[v]=rosso)then
  21.         dist[v]=dist[u]+1;
  22.         if(color[v]=rosso)then
  23.           if(dist[v]<=k)then
  24.             return false;
  25.         color[v]=grigio;
  26.         Q=Accoda(Q,v);
  27.     color[u]=nero;
  28.     Q=Decoda(Q);
  29.   return true;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top