Breath-First Search algorithm C++
I have to implement BFS algorithm for connected and disconnected graphs that returns the order of visited vertices. For connected graph everytihing is ok, but for disconnected one I have to do it in such a way that every vertex is visited also those in other connected components. In each component it should be done in according to BFS. First component start from the vertex start. I tried few things but it didn't work. If somebody could give me some hints, I would be grateful. I have also methods given below.
1 if given vertices are connected by an egde
0 if the vertices are not connected
-1 if the vertices do not exist
Returns number of vertices
Returns number of edges
degree of the given vertex
-1 if no such vertex exists.
a pointer to the list of neighbors of a given vertex (for isolated vertex list is empty)
null if no such vertex exists
|All times are GMT +5.5. The time now is 03:39.|