private static IEnumerable<Step> GetPathFrom(NodeV3 goalNode1)
 {
     for (NodeV3 current = goalNode1; current.ParentNode != null && current.PreviousStep != null; current = current.ParentNode)
     {
         yield return current.PreviousStep.Value;
     }
 }
        public void Enqueue(NodeV3 node)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }

            int newIndex = this.binaryHeap.Count;
            this.binaryHeap.Add(node);
            this.hashSet.Add(node);

            while (newIndex > 0)
            {
                int parentIndex = (newIndex - 1) / 2;
                if (this.binaryHeap[parentIndex].Cost <= node.Cost)
                {
                    break;
                }

                this.binaryHeap[newIndex] = this.binaryHeap[parentIndex];
                newIndex = parentIndex;
            }

            this.binaryHeap[newIndex] = node;
        }
        public bool Contains(NodeV3 node)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }

            return this.hashSet.Contains(node);
        }
Esempio n. 4
0
 public void AddChild(NodeV3 child)
 {
     Childs.Add(child);
     ++child.NbParents;
 }