Guest User

Untitled

a guest
Jun 15th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. struct finder
  2. {
  3.   int cu;
  4.   int depth;
  5. };
  6. int distances[zoneCount][zoneCount];
  7.  
  8. for(int i=0;i<zoneCount;i++)
  9.     {
  10.       queue<finder>BFS;
  11.       BFS.push({i,0});
  12.       int visited[zoneCount];
  13.       for(int n=0;n<zoneCount;n++)
  14.       {
  15.           visited[n]=0;
  16.       }      
  17.       visited[i]=1;
  18.       cerr<<"For zone "<<i<<endl;
  19.       while(BFS.size()>0)
  20.       {
  21.           finder th=BFS.front();//th you can refer this cell
  22.           BFS.pop();
  23.           distances[th.cu][i]=th.depth;
  24.           int children=got[th.cu];
  25.          
  26.           for(int f=0;f<children;f++)
  27.           {
  28.               if(visited[links[th.cu][f]]!=1){
  29.               BFS.push({links[th.cu][f],th.depth+1});
  30.               visited[links[th.cu][f]]=1;}
  31.           }
  32.       }
  33.     }
Add Comment
Please, Sign In to add comment