

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


#include
if (i >= 0 && i < vertexCount && j >= 0 && j < vertexCount) return adjMatrix[i][j]; else{ cout<<"Invalid vertex number.\n"; return false; } } void Graph::display(){ int u,v; //vertex for(u=0; u<vertexCount; ++u) { cout << "\nadj[" << (char) (u+48) << "] -> "; for(v=0; v<vertexCount; ++v) { cout << " " << adjMatrix[u][v]; } } cout << "\n\n"; } // This BFS method is a member of Graph class // Develop a member function is a better choice void Graph::BFS(int startNode){ cout<<"Start BFS Member Function... \n"; int *state; state = new int[this->vertexCount]; for(int i=0; i<this->vertexCount; i++) { state[i] = 0; // 0=undiscovered, 1=discovered, 2=processed } state[startNode]=1; //discovered start node queue