Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //latime || cuprindere
- int viz[100], a[100][100], n,m;
- void bfs(int s){
- int p,u,i,j;
- p = u = 1;
- c[1]=s;
- viz[s]=1;
- d[s]=0;
- while(p<=u)
- {
- i=c[p]; p=p+1;
- cout<<i<<" ";
- for(j=1;j<=n;j++)
- if(a[i][j]==1)
- if(viz[j]==0)
- {
- u=u+1; c[u]=j;
- viz[j]=1;
- tata[j]=i;
- d[j]=d[i]+1;
- }
- }
- }
- //adancime
- int viz[100], a[100][100], n,m;
- void dfs(int k)
- {
- viz[k]=1;
- for(int i=1;i<=n;i++)
- if(a[k][i]==1 && viz[i]==0)
- {
- dfs(i);
- }
- }
Add Comment
Please, Sign In to add comment