public void Degree_RemoveLargeSubTree_DegreeRecalculated() { var a1 = FibonacciHeapTestHelpers.CreateNodeConnectedToSelf(6); var a2 = FibonacciHeapTestHelpers.CreateNodeConnectedToSelf(7); _heap.AddChild(a1, a2); var b1 = FibonacciHeapTestHelpers.CreateNodeConnectedToSelf(8); var b2 = FibonacciHeapTestHelpers.CreateNodeConnectedToSelf(9); var b3 = FibonacciHeapTestHelpers.CreateNodeConnectedToSelf(10); var b4 = FibonacciHeapTestHelpers.CreateNodeConnectedToSelf(11); _heap.AddChild(b1, b2); _heap.AddChild(b2, b3); _heap.AddChild(b3, b4); var c1 = FibonacciHeapTestHelpers.CreateNodeConnectedToSelf(12); var c2 = FibonacciHeapTestHelpers.CreateNodeConnectedToSelf(13); _heap.AddChild(c1, c2); _heap.AddChild(a1, b1); _heap.AddChild(a1, c1); Assert.AreEqual(4, a1.Degree); _heap.Cut(b1); Assert.AreEqual(2, a1.Degree); }
public void Cut_1Node_CorrectNextPrev() { var p1 = FibonacciHeapTestHelpers.CreateNodeConnectedToSelf(1); _heap.Cut(p1); Assert.Multiple(() => { Assert.AreEqual(p1, p1.Next); Assert.AreEqual(p1, p1.Prev); }); }