#include#include #include #include using namespace std; const int MAX=1010; bool tag[MAX]; //标记BFS是是否被访问过 struct node { int ID; //编号 int layer; //层号 }; vector Adj[MAX]; //邻接表,每个位置都是一个node queue q; //BFS待查询队列 int BFS(int s,int l) //起始点s,极限传播层数l { int transNum=0; //转发次数 node start; start.ID=s; start.layer=0; q.push(start); tag[s]=1; while(!q.empty()) { node tmp=q.front(); q.pop(); int u=tmp.ID; for(int i=0 ; i