借助队列处理
void Unweighted(Table T) { Queue Q; Vertext V, W; Q = CreateQueue(NumVertex); MakeEmpty(Q); Enqueue(S, Q); while (!IsEmpty(Q)) { V = Dequeue(Q); T[V].Know = True; for each W adjacent to V if (T[V].Dist + Cvw < T[W].Dist) { T[W].Dist = T[V].Dist + Cvw; T[W].Path = V; if (W is not in Q) Enqueue(W, Q); } } DisPoseQueue(Q); }
时间: 2024-10-23 19:54:52