public void EmptyHeapContainsNode_False()
    {
        FibonacciHeap <int> heap = new FibonacciHeap <int>();
        FibonacciNode <int> node = new FibonacciNode <int>(3);

        NUnit.Framework.Assert.IsFalse(heap.Contains(node));
    }
Ejemplo n.º 2
0
        public void FibonacciHeapContainsTest()
        {
            FibonacciHeap <Int32, String> heap = new FibonacciHeap <Int32, String>(this.values);

            for (Int32 number = -1000; number < 1000; number++)
            {
                heap.Contains(number).ShouldBe(this.values.Contains(new KeyValuePair <Int32, String>(number, number.ToString())));
            }
        }
    public void UnconsolidatedHeapContainsNull_false()
    {
        FibonacciHeap <int> heap  = new FibonacciHeap <int>();
        IList <int>         input = new List <int>()
        {
            0,
            28,
        };

        NUnit.Framework.Assert.IsFalse(heap.Contains(null));
    }
Ejemplo n.º 4
0
    private void ExpandNode(AStarNode node)
    {
        ISet <ILevelTile> neighbours = graphProvider.GetConnectedNavPoints(node.tile);

        foreach (ILevelTile neighbour in neighbours)
        {
            // Obtain node for neighbour point
            if (tilesToNodes.TryGetValue(neighbour, out AStarNode neighbourNode) == false)
            {
                neighbourNode = new AStarNode(neighbour, heuristic.GetDistance(neighbour.CenterPos, target.CenterPos));
                tilesToNodes.Add(neighbour, neighbourNode);
            }

            if (closedNodes.Contains(neighbourNode))
            {
                continue;
            }

            float newCost = node.cost + Vector2.Distance(node.tile.CenterPos, neighbour.CenterPos);
            if (openNodes.Contains(neighbourNode))
            {
                if (newCost >= neighbourNode.cost)
                {
                    continue;
                }
            }

            neighbourNode.predecessor = node;
            neighbourNode.cost        = newCost;
            float fVal = neighbourNode.cost + neighbourNode.heuristicValue;
            if (openNodes.Contains(neighbourNode))
            {
                openNodes.DecreaseKey(neighbourNode, fVal);
            }
            else
            {
                neighbourNode.key = fVal;
                openNodes.Insert(neighbourNode);
            }
        }
    }
    public void UnconsolidatedHeapContainsNode_False()
    {
        FibonacciNode <int> node  = new FibonacciNode <int>(-3);
        FibonacciHeap <int> heap  = new FibonacciHeap <int>();
        IList <int>         input = new List <int>()
        {
            0,
            28,
            -13,
            80
        };

        foreach (int value in input)
        {
            heap.Insert(value);
        }

        NUnit.Framework.Assert.IsFalse(heap.Contains(node));
    }