Exemple #1
0
        static void Main(string[] args)
        {
            DepthFirstAlgorithm b    = new DepthFirstAlgorithm();
            Employee            root = b.BuildEmployeeGraph();

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

            Console.WriteLine("\nSearch in graph\n------");
            Employee e = b.Search(root, "Eva");                           // root es Eva con su lista de trabajadores

            Console.WriteLine(e == null ? "Employee not found" : e.name); // ? es un if ternario, una condicion. Si se cumple la condicion, ejecútame lo de la izquierda.
            e = b.Search(root, "Brian");                                  // pasasmos el root como Eva, pero el name to search es Brian, tengo que llamarme a mi mismo
            Console.WriteLine(e == null ? "Employee not found" : e.name);
            e = b.Search(root, "Soni");
            Console.WriteLine(e == null ? "Employee not found" : e.name);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            DepthFirstAlgorithm bfA  = new DepthFirstAlgorithm();
            Employee            root = bfA.BuildEmployeeGraph();

            Console.WriteLine("Travers Graph\n----");
            bfA.Traverse(root);

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

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