Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void bfs(int v,int end) {
- queue<int> q;
- q.push(v);
- used[v] = 1;
- while (v == end) {
- for (int i = 1; i <= n; i++) {
- if (used[i] == 0 && mas[v][i] == 1) {
- q.push(i);
- used[i] = 1;
- }
- }
- q.pop();
- v = q.front();
- }
- }
Add Comment
Please, Sign In to add comment