static void Main(string[] args) { Node root = new Node(1, 0, 0, null); DFS dfs = new DFS(); List <Node> path = new List <Node>(); Console.WriteLine("Depth Search with limit"); Console.WriteLine("Jar1 = 9 Jar2 = 5 Limit= 20"); try { path = dfs.Search(root, new List <Node>()); Console.WriteLine("Path:"); dfs.GetPath(path); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.ReadLine(); }
static void Main(string[] args) { Node root = new Node(1, 0, 0, null); DFS dfs = new DFS(); dfs.Search(root); dfs.GetPath(); Console.WriteLine(); foreach (var n in dfs.visited) { Console.WriteLine(n); } Console.ReadLine(); }