private void Traversal(INodeMinMax <T> node) { if (node == null) { return; } INodeMinMax <T> next = node.FindFirstFree() as INodeMinMax <T>; if (next != null) { _stack.Push(next); _depth++; Traversal(next); } else { next = _stack.Pop(); _depth--; next.Value = _minMaxPriority.GetPriority(_depth) == PriorityType.MIN ? next.GetMinChild() : next.GetMaxChild(); next.Debug(); next.IsVisited = true; if (_stack.Count > 0) { Traversal(_stack.Peek()); } } }
private void Traversal(INodeMinMax <T> node) { if (node == null) { return; } INodeMinMax <T> next = node.FindFirstFree() as INodeMinMax <T>; if (next != null) { _stack.Push(next); _depth++; Traversal(next); } else { next = _stack.Pop(); _depth--; next.Debug(); next.IsVisited = true; if (_stack.Count > 0) { Traversal(_stack.Peek()); } } }
public void Load(MatrixAdjacency matrix, T[] values) { _list = new INodeMinMax <T> [matrix.CountAll + 1]; for (int i = 0; i < _list.Length; i++) { _list[i] = new NodeMinMax <T>(i); } for (int i = 0; i < matrix.CountKey; i++) { if (matrix.ContainsKey(i) == true) { for (int j = 0; j < matrix[i].Length; j++) { _list[matrix[i][j]].Parent = _list[i]; _list[i].AddChild(_list[matrix[i][j]]); } } } Head = _list[0]; for (int i = _list.Length - values.Length, j = 0; i < _list.Length; i++, j++) { _list[i].Value = values[j]; } }
private void Pruning(INodeMinMax <T> node) { if (node.Parent == null) { return; } if (node.Parent.IsValueLeftNode(node) == false) { return; } ; var priority = _minMaxPriority.GetPriority(_depth); var pastLeft = node.Parent.GetValueLeftNode(node); int index = 0; for (index = 0; index < node.Nodes.Count; index++) { if (priority == PriorityType.MIN && node.Nodes[index].Value.CompareTo(pastLeft) > 0 || priority == PriorityType.MAX && node.Nodes[index].Value.CompareTo(pastLeft) < 0) { break; } } index++; for (; index < node.Nodes.Count; index++) { node.Nodes[index].Value = priority == PriorityType.MIN ? INodeMinMax <T> .Max : INodeMinMax <T> .Min; } }