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); }
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); }
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); }
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); }
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); }