c++ - BFS algorithm implementation -


here code implements bfs method

#include<iostream> #include<stack> #define max 100  using namespace std;  queue<int> mystack; int g[max][max]; int visit[max]; int v, e;   void bfs(int s) {      int i, j, node;      memset(visit, 0, sizeof(visit));      mystack.push(s);       while(!mystack.empty())      {           node = mystack.top();           mystack.pop();           if(visit[node]) continue;           visit[node] = 1;           cout << node << " ";            for(i=0; i<v; i++)                if(g[node][i]) mystack.push(i);      }  }  int main() {     memset(visit, 0, sizeof(visit));     bfs(0);     return 0; } 

i have question how can create real graph,i mean enter graph , using bfs method baisc bfs operation?i need in completing algorithm real graph


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -