Sunday 13 October 2013

Breadth First Search

Step1 : Choose any node in the graph,designate it as search node and mark it as visited.
Step2 : Using Adjacency matrix of the graph,find all unvisited adjacent nodes to the search node and enqueue them on to a Queue
Step3 : Then the node is dequeued from the queue.Mark the node as visited and designate it as the source node.
Step4 : Repeat step2 and step3 using the new search node.
Step5 : Repeat these process until the queue which keeps track of the adjacent nodes is empty.

No comments:

Post a Comment