পোস্টগুলি

এপ্রিল, ২০১৭ থেকে পোস্টগুলি দেখানো হচ্ছে

BSF

#include<iostream> #include<queue> #include<vector> using namespace std; int main() {     int edges,a,b;     vector<int>nodes[1000];     cout<<"Enter the no of edges"<<endl;     cin>>edges;     for(int i=0; i<edges; i++)     {         cin>>a>>b;         nodes[a].push_back(b);         nodes[b].push_back(a);     }     cout<<endl;     //Adj list representation     for(int i=0; i<1000; i++)     {         if(!nodes[i].empty())         {             cout<<"[ "<<i<<" ]"<<"-->";             for(vector<int>::iterator it=nodes[i].begin();                     it!=nodes[i].end(); ++it)             {                 cout<<*it<<"-->";             }             cout<<"NULL"<<endl;         }     }     queue<int> que; //initially que is empty     bool visited[1000]; // mark al