static void Main(string[] args) { var t = TreeCreator.CreateTree(); //DepthPreOrderNLR(t); //DepthInOrderLNR(t); //DepthPostOrderLRN(t); var q = new Queue <TreeNode>(); BreadthSearch.BreadthFirstSearch_BottomTopLeftRight(t, q, new Stack <TreeNode>()); System.Console.WriteLine(); System.Console.WriteLine("Program end."); System.Console.Read(); }
// Ensure that an input grid point is open space, if not find nearest that is public IntVector2 NearestGridOpenSpace(IntVector2 inpos) { if (IsGridOpenSpace(inpos)) { return(inpos); } // Find nearest open space with breadth search var graph = new MapWeightedGraph(this); var bfs = new BreadthSearch <IntVector2>(); Func <IntVector2, bool> f = (pos) => { return(IsGridOpenSpace(pos)); }; var path = bfs.GetPath(inpos, f, graph); if (path.Count > 0) { return(path[path.Count - 1]); } UberDebug.LogError("Unable to find any open space in map near {0}! Should never happen", inpos); return(new IntVector2(0, 0)); }