コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: Starup.cs プロジェクト: darkyto/Workshops
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
    public void DFS()
    {
        RefreshGrid();

        var watch = System.Diagnostics.Stopwatch.StartNew();

        DepthFirstAlgorithm depthFirstAlgorithm = new DepthFirstAlgorithm(MapProperties.height, MapProperties.width, MapGenerator.gridArray);

        depthFirstAlgorithm.CreateGrid();
        depthFirstAlgorithm.Search();

        if (depthFirstAlgorithm.results.Count > 0)
        {
            ingamePopup.SetActive(false);
            depthFirstAlgorithm.ShowPath();
        }
        else
        {
            depthFirstAlgorithm.ShowPath();
            BroadcastInfoPopUp("No available path");
        }

        watch.Stop();
        Debug.Log(watch.ElapsedMilliseconds);
    }
コード例 #5
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);
    }
コード例 #6
0
ファイル: DepthFirst.cs プロジェクト: snaptothegrid/NodeGraph
	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);
	}