static void Main(string[] args)
        {
            //BFS
            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);

            //DFS
            DepthFirstAlgorithm d     = new DepthFirstAlgorithm();
            Employee            rootD = d.BuildEmployeeGraph();

            Console.WriteLine("Traverse Graph\n------");
            d.Traverse(rootD);

            Console.WriteLine("\nSearch in Graph\n------");
            Employee emp = d.Search(root, "Eva");

            Console.WriteLine(emp == null ? "Employee not found" : emp.name);
            emp = d.Search(root, "Brian");
            Console.WriteLine(emp == null ? "Employee not found" : emp.name);
            emp = d.Search(root, "Soni");
            Console.WriteLine(emp == null ? "Employee not found" : emp.name);
        }
Exemplo n.º 2
0
            static void Main(string[] args)
            {
                DepthFirstAlgorithm b    = new DepthFirstAlgorithm();
                Employee            root = b.BuildEmployeeGraph();

                Console.WriteLine("Traverse Graph\n------");
                b.TraverseDFS(root);

                Console.WriteLine("\nSearch in Graph\n------");
                Employee e = b.SearchDFS(root, "Eva");

                Console.WriteLine(e == null ? "Employee not found" : e.name);
                e = b.SearchDFS(root, "Brian");
                Console.WriteLine(e == null ? "Employee not found" : e.name);
                e = b.SearchDFS(root, "Soni");
                Console.WriteLine(e == null ? "Employee not found" : e.name);
            }