Exemple #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Node"/> class.
 /// </summary>
 /// <param name="parent">The parent.</param>
 /// <param name="successor">The successor.</param>
 public Node(Node parent, ISuccessor successor)
 {
     State = successor.State;
     Parent = parent;
     Successor = successor;
     Cost = parent.Cost + successor.Cost;
     Depth = parent.Depth + 1;
     Path = false;
     Children = new List<Node>();
     _stateComparer = new StateComparer();
 }
Exemple #2
0
        /// <summary>
        /// Adds the child.
        /// </summary>
        /// <param name="n">The n.</param>
        /// <exception cref="System.InvalidOperationException">Invalid node state!</exception>
        public void AddChild(Node n)
        {
            if (State == null)
                throw new InvalidOperationException("Invalid node state!");

            Children.Add(n);
        }