#include #include #include using namespace std; vector > graph; voidbfs(int v){ vector::iterator it; visited[v] = true; cout << v << " "; queue q; q.push(v); while(!q.empty()){ v = q.front(); q.pop(); for(it = graph[v].begin(); it != graph[v].end(); it++){ if(!visited[*it]){ cout << *it << " "; q.push(*it); visited[*it] = true; } } cout << endl; } }