Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void BFS(City* start, City** Cities)
- {
- int visited[21] = { 0 };
- QHead* QueueHead = (QHead*)calloc(1, sizeof(QHead));
- QPush(start, QueueHead);
- visited[start->citynum] = 1;
- while (!QIsEmpty(QueueHead))
- {
- City* v = QTop(QueueHead);
- // cout << v->citynum<<" ";
- Con* p = Cities[v->citynum-1]->Head->pHead;
- while (p)
- {
- int b = p->cityB;
- if (!visited[b])
- {
- QPush(Cities[b - 1], QueueHead);
- cout << Time(p)<<endl;
- p->time = Time(p);
- visited[b] = 1;
- }
- p = p->next;
- }
- }
- FreeQ(QueueHead);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement