Google Ads

Sunday, September 13, 2009

Graph Traversal using BFS


Breadth-first search

Aim : Program to demonstrate Graph Traversal using BFS

Algorithm:

Step 1: Consider any vertex in the graph. Process the vertex A and mark it as visited.

Step 2: Using the adjacency matrix of the graph proceed to the next vertex which has an edge connection wise the vertex considered in step 1.

Step 3: Backtrack to the vertex considered in step 1 descend along an edge towards an unvisited vertex and mark the new vertex as visited

Step 4: Repeat step3 until all vertices adjacent to the node in step 1 have been marked as visited.

Step 5: Stop the execution

No comments:

Post a Comment