Skip to content

Commit 3ea2a4b

Browse files
committed
Fix typo
1 parent 3930a1c commit 3ea2a4b

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

graph_theory/graph_traversal/breadth_first_search.cpp

+16-5
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,24 @@ void _clear() {
2323
void BFS(int src) {
2424
memset(dis, 0x3f, sizeof(dis[0]) * (n + 2));
2525
memset(Par, -1, sizeof(Par[0]) * (n + 2));
26-
wdwadfppfnqkpfigikw;
27-
lgfdjklsaigrkf,sdapgkz
28-
}
26+
27+
queue <int> q;
28+
q.push(src);
29+
dis[src] = 0;
30+
31+
int u;
32+
while(q.size()) {
33+
u = q.front(); q.pop();
34+
for(int i = Head[u]; i; i = Next[i])
35+
if(dis[To[i]] == oo) {
36+
dis[To[i]] = dis[u] + 1;
37+
Par[To[i]] = u;
38+
q.push(To[i]);
39+
}
40+
}
2941
}
3042

31-
int main()
43+
int main()
3244
{
3345
cin >> n >> m >> st >> tr;
3446
while(m--) {
@@ -40,4 +52,3 @@ int main()
4052
BFS(st);
4153
cout << dis[tr] << endl;
4254
}
43-

0 commit comments

Comments
 (0)