Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void bfs(int s, vector<int> adj[], bool vis[], int N)
- {
- queue<int> q;
- q.push(s);
- while(!q.empty()){
- int top =q.front();
- for (auto x : adj[top])
- if (!vis[x])
- q.push(x);
- cout << top << ' ';
- vis[top] = true;
- q.pop();
- }
- cout << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement