1 2 3 4 5 6 7 8 9 10 11 12 | const int maxn = 10000 + 100;const int maxedge = (50000 + 100)*2;int head[maxn];//head[i]表示第i个顶点,第一个链节的编号int next[maxedge];//表示 第 q 号链节,下一个链节的编号int end[maxedge];//表示 第 q 个链节 的终点int vis[maxedge];//表示第q个链节是否被访问过.void addedge(int from,int to){ static int q = 2; end[q] = to; next[q] = head[from]; head[from] = q++;} |
1 2 3 4 | for(int q = head[cur];q;q = next[q]) { //do some thing. } |
原文:http://www.cnblogs.com/qhy285571052/p/5164723.html