Пример #1
0
        public void Iterate_Siblings_Success()
        {
            var p1 = FibonacciHeapTestHelpers.CreateNodeConnectedToSelf(1);
            var p2 = FibonacciHeapTestHelpers.CreateNodeConnectedToSelf(2);
            var p3 = FibonacciHeapTestHelpers.CreateNodeConnectedToSelf(3);

            _heap.Join(p2, p3);
            _heap.Join(p1, p2);

            var actual = NodeDebugTools <int> .IterateSiblings(p1).ToList();

            Assert.Multiple(() =>
            {
                Assert.AreEqual(3, actual.Count());
                Assert.AreEqual(1, actual[0].Value);
                Assert.AreEqual(2, actual[1].Value);
                Assert.AreEqual(3, actual[2].Value);
            });
        }
Пример #2
0
        public void JoinNodes_2Nodes_CorrectNextAndPrev()
        {
            var p1 = FibonacciHeapTestHelpers.CreateNodeConnectedToSelf(1);
            var p2 = FibonacciHeapTestHelpers.CreateNodeConnectedToSelf(2);

            _heap.Join(p1, p2);

            Assert.Multiple(() =>
            {
                Assert.AreEqual(p2, p1.Prev);
                Assert.AreEqual(p2, p1.Next);

                Assert.AreEqual(p1, p2.Prev);
                Assert.AreEqual(p1, p2.Next);
            });
        }
        public void Consolidate_2Node_CorrectSiblings()
        {
            var node1 = FibonacciHeapTestHelpers.CreateNodeConnectedToSelf(5);
            var node2 = FibonacciHeapTestHelpers.CreateNodeConnectedToSelf(6);

            _heap.Join(node1, node2);
            _heap.Consolidate(node1, 2);

            Assert.Multiple(() =>
            {
                Assert.AreEqual(node1, node1.Prev);
                Assert.AreEqual(node1, node1.Next);

                Assert.AreEqual(node2, node2.Prev);
                Assert.AreEqual(node2, node2.Next);
            });
        }