练习6.2 邻接表存储图的广度优先遍历 (20分)
代码:
void BFS ( LGraph Graph, Vertex S, void (*Visit)(Vertex) )
{
int node[Graph->Nv], start = 0, end = 0;
node[end++] = S;
while (start < end) {
Visited[node[start]] = true;
Visit(node[start]);
PtrToAdjVNode g = Graph->G[node[start++]].FirstEdge;
while (g) {
if (!Visited[g->AdjV]) {
Visited[g->AdjV] = true;
node[end++] = g->AdjV;
}
g = g->Next;
}
}
}