irapilguy

Untitled

Nov 14th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.24 KB | None | 0 0
  1. void bfs(int v) {
  2.     queue<int> q;
  3.     q.push(v);
  4.     used[v] = 1;
  5.     while (q.size != 0) {
  6.         for (int i = 1; i <= n; i++) {
  7.             if (used[i] == 0 && mas[v][i] == 1) {
  8.                 q.push(i);
  9.                 used[i] = 1;
  10.             }
  11.         }
  12.         q.pop();
  13.         bfs(q.front());
  14.     }
  15. }
Add Comment
Please, Sign In to add comment