标签:
head=1; tail=1; que[head]=1; while(head<=tail){ for(i=2;i<=n;i++){ if(map[que[head]][i]==1 && dist[i]==0){ que[++tail]=i; dist[i]=dist[que[head]]+1; } } head++; }
今日才真正懂了BFS
原文地址:http://www.cnblogs.com/peccavi/p/4978459.html