Sunday 13 October 2013

Depth 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 a node adjacent nodes to the search node that has been not yet visited and designate that node as the search node and mark it as visited.
Step3 : Repeat Step2 using the new search node.If no nodes satisfying Step2 is found,return to the previous search node and continue from there.
Step4 : When a return to the previous search node in Step3 is impossible,the search from the originally chosen node is complete.
Step5 : If the graph still contains unvisited nodes,choose any node that has not yet been visited and repeat Step 1 to 4.

No comments:

Post a Comment