Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct finder
- {
- int cu;
- int depth;
- };
- int distances[zoneCount][zoneCount];
- for(int i=0;i<zoneCount;i++)
- {
- queue<finder>BFS;
- BFS.push({i,0});
- int visited[zoneCount];
- for(int n=0;n<zoneCount;n++)
- {
- visited[n]=0;
- }
- visited[i]=1;
- cerr<<"For zone "<<i<<endl;
- while(BFS.size()>0)
- {
- finder th=BFS.front();//th you can refer this cell
- BFS.pop();
- distances[th.cu][i]=th.depth;
- int children=got[th.cu];
- for(int f=0;f<children;f++)
- {
- if(visited[links[th.cu][f]]!=1){
- BFS.push({links[th.cu][f],th.depth+1});
- visited[links[th.cu][f]]=1;}
- }
- }
- }
Add Comment
Please, Sign In to add comment