C Program to implement BFS Algorithm for Disconnected Graph

By | 23.05.2017

BFS Algorithm for Disconnected Graph

Write a C Program to implement BFS Algorithm for Disconnected Graph. Here’s simple Program for traversing a directed graph through Breadth First Search(BFS),  visiting all  vertices that are reachable or not reachable from start vertex.

Breadth First Search (BFS)

BFS is a traversing algorithm where you should start traversing from a selected node (source or starting node) and traverse the graph layerwise thus exploring the neighbour nodes (nodes which are directly connected to source node). You must then move towards the next-level neighbour nodes.

It employs the following rules :

  • Rule 1 − Visit the adjacent unvisited vertex. Mark it as visited. Display it. Insert it in a queue.
  • Rule 2 − If no adjacent vertex is found, remove the first vertex from the queue.
  • Rule 3 − Repeat Rule 1 and Rule 2 until the queue is empty.

Also Read : : C Program for Creation of Adjacency Matrix

Below is the source code for C Program to implement BFS Algorithm for Disconnected Graph which is successfully compiled and run on Windows System to produce desired output as shown below :



If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval.

Thanks for reading the post…

Recommended Posts : :

0 0 vote
Article Rating
Notify of
Inline Feedbacks
View all comments