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);
        }
Example #2
0
        static void Main(string[] args)
        {
            DepthFirstAlgorithm dfs = new DepthFirstAlgorithm();
            Person root = dfs.BuildFriendGraph();
            Console.WriteLine("Traverse\n------");
            dfs.Traverse(root, 1);

            Console.WriteLine("\nSearch\n------");
            Person p = dfs.Search(root, "Catherine");
            Console.WriteLine(p == null ? "Person not found" : p.Name);
            p = dfs.Search(root, "Alex");
            Console.WriteLine(p == null ? "Person not found" : p.Name);
        }
        static void Main(string[] args)
        {
            DepthFirstAlgorithm b = new DepthFirstAlgorithm();
            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);
        }
Example #4
0
    public void Main()
    {
        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");

        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);
    }
        private void searchBomb(double x, double y)
        {
            var b = new DepthFirstAlgorithm();
            //Console.WriteLine("actual x: " + CanvasLeft);
            var root = b.BuildVertGraph(x, y, _direction);

            b.Traverse(root);
            _treePositions = b.getPath();
            if (_treePositions[0].x == 650 && _direction == "right")
            {
                _treePositions.Add(new Vert(700, _treePositions[0].y + 50));
                _treePositions.Add(new Vert(700, _treePositions[0].y + 100));
                _direction = "left";
                _started   = false;
            }
            if (_treePositions[0].x == 50 && _direction == "left")
            {
                _treePositions.Add(new Vert(0, _treePositions[0].y + 50));
                _treePositions.Add(new Vert(0, _treePositions[0].y + 100));
                _direction = "right";
                _started   = false;
            }
            //Console.WriteLine(treePositions[0]);
        }
Example #6
0
	public void Main(GameObject personPrefab, GameObject pathPrefab) { // string[] args
		

		DepthFirstAlgorithm b = new DepthFirstAlgorithm();
		Person root = b.BuildFriendGraph();
		
		Debug.Log("Traverse\n------");
		b.Traverse(root, personPrefab, pathPrefab);

		Debug.Log("\nSearch\n------");
		Person p = b.Search(root, "Catherine");
		Debug.Log(p == null ? "Person not found" : p.name);
		//p = b.Search(root, "Alex");
		//Debug.Log(p == null ? "Person not found" : p.name);
	}