Ejemplo n.º 1
0
        private void CheckHeap(FibonacciHeap <int> heap)
        {
            FibonacciNode <int> prePeak = null;

            while (!heap.IsEmpty)
            {
                var peak = heap.Extract();

                Console.WriteLine();
                Console.WriteLine($"Extract {peak}");

                heap.Traverse(heap.Peak,
                              (node) =>
                {
                    Console.Write($"{node} ");
                }
                              );

                if (prePeak == null)
                {
                    prePeak = peak;
                }
                else
                {
                    Assert.IsTrue(prePeak.Key < peak.Key);
                    prePeak = peak;
                }
            }
        }