static void Main(string[] args) { BreadthFirstAlgorithm b = new BreadthFirstAlgorithm(); Person root = b.BuildFriendGraph(); Console.WriteLine("Traverse\n------"); b.Traverse(root); Console.WriteLine("\nSearch\n------"); Person p = b.Search(root, "Catherine"); Console.WriteLine(p == null ? "Person not found" : p.name); p = b.Search(root, "Alex"); Console.WriteLine(p == null ? "Person not found" : p.name); }
static void Main(string[] args) { BreadthFirstAlgorithm b = new BreadthFirstAlgorithm(); Employee root = b.BuildEmployeeGraph(); Console.WriteLine("Traverse Graph\n------"); b.Traverse(root); Console.WriteLine("\nSearch in Graph\n------"); Employee e = b.Search(root, "Eva"); Console.WriteLine(e == null ? "Employee not found" : e.name); e = b.Search(root, "Brian"); Console.WriteLine(e == null ? "Employee not found" : e.name); e = b.Search(root, "Soni"); Console.WriteLine(e == null ? "Employee not found" : e.name); }