Beispiel #1
0
        public void DecreaseKey(FibonacciNode <TK> x, TK k)
        {
            if (k.CompareTo(x.Key) > 0)
            {
                throw new InvalidOperationException($"new key {k} is greater than the current key {x.Key}");
            }
            x.Key = k;
            var y = x.Parent;

            if (y != null && x.CompareTo(y) < 0)
            {
                Cut(x, y);
                CascadingCut(y);
            }
            if (x.CompareTo(Min) < 0)
            {
                Min = x;
            }
        }
Beispiel #2
0
 public void Insert(FibonacciNode <TK> node)
 {
     if (Min == null)
     {
         AddToRootList(node);
         Min = node;
     }
     else
     {
         AddToRootList(node);
         if (node.CompareTo(Min) < 0)
         {
             Min = node;
         }
     }
     Count++;
 }