Joe Wilson

Joe Wilson

  • NA
  • 7.8k
  • 432.7k

How to implement BFS and DFS algorithm in c++?

Oct 23 2015 1:46 PM
I mean I want to implement BFS algorithm first .
 
1)first of all I want to ask user to enter the size of adjacency matrix of graph then ask user to enter the elements of adjacency matrix then I need a class or struct which contain the features of a node as depth and the cost of node (gn: the cost of n node which must be paid to arrive root node) and  name of state and node * parent , next I want to implement BFS ALGORITHM using class elements then I want to use the answer of BFS TO extract DFS algorithm answer just by sorting answer according to feature of DFS algorithm and I want to calculate the time complexity too,
please guide me to do that. Thank you