src/main/java/com/mxgraph/analysis/mxFibonacciHeap.java
protected void consolidate()
	{
		int arraySize = size + 1;
		Node[] array = new Node[arraySize];

		// Initialize degree array
		for (int i = 0; i < arraySize; i++)
		{
			array[i] = null;
		}

		// Find the number of root nodes.
		int numRoots = 0;
		Node x = min;

		if (x != null)
		{
			numRoots++;
			x = x.right;

			while (x != min)
			{
				numRoots++;
				x = x.right;
			}
		}

		// For each node in root list do...
		while (numRoots > 0)
		{
			// Access this node's degree..
			int d = x.degree;
			Node next = x.right;

			// ..and see if there's another of the same degree.
			while (array[d] != null)
			{
				// There is, make one of the nodes a child of the other.
				Node y = array[d];

				// Do this based on the key value.
				if (x.key > y.key)
				{
					Node temp = y;
					y = x;
					x = temp;
				}

				// Node y disappears from root list.
				link(y, x);

				// We've handled this degree, go to next one.
				array[d] = null;
				d++;
			}

			// Save this node for later when we might encounter another
			// of the same degree.
			array[d] = x;

			// Move forward through list.
			x = next;
			numRoots--;
		}

		// Set min to null (effectively losing the root list) and
		// reconstruct the root list from the array entries in array[].
		min = null;

		for (int i = 0; i < arraySize; i++)
		{
			if (array[i] != null)
			{
				// We've got a live one, add it to root list.
				if (min != null)
				{
					// First remove node from root list.
					array[i].left.right = array[i].right;
					array[i].right.left = array[i].left;

					// Now add to root list, again.
					array[i].left = min;
					array[i].right = min.right;
					min.right = array[i];
					array[i].right.left = array[i];

					// Check if this is a new min.
					if (array[i].key < min.key)
					{
						min = array[i];
					}
				}
				else
				{
					min = array[i];
				}
			}
		}
	}
/**
	 * Consolidates the trees in the heap by joining trees of equal degree until
	 * there are no more trees of equal degree in the root list.
	 * 
	 * <p>
	 * Running time: O(log n) amortized
	 * </p>
	 */
Consolidates the trees in the heap by joining trees of equal degree until
there are no more trees of equal degree in the root list.


Running time: O(log n) amortized

Consolidates the trees in the heap by joining trees of equal degree until there are no more trees of equal degree in the root list . Running time : O ( log n ) amortized
protected void consolidate()
	{
		int arraySize = size + 1;
		Node[] array = new Node[arraySize];
		for (int i = 0; i < arraySize; i++)
		{
			array[i] = null;
		}
		int numRoots = 0;
		Node x = min;
		if (x != null)
		{
			numRoots++;
			x = x.right;
			while (x != min)
			{
				numRoots++;
				x = x.right;
			}
		}
		while (numRoots > 0)
		{
			int d = x.degree;
			Node next = x.right;
			while (array[d] != null)
			{
				Node y = array[d];
				if (x.key > y.key)
				{
					Node temp = y;
					y = x;
					x = temp;
				}
				link(y, x);
				array[d] = null;
				d++;
			}
			array[d] = x;
			x = next;
			numRoots--;
		}
		min = null;
		for (int i = 0; i < arraySize; i++)
		{
			if (array[i] != null)
			{
				if (min != null)
				{
					array[i].left.right = array[i].right;
					array[i].right.left = array[i].left;
					array[i].left = min;
					array[i].right = min.right;
					min.right = array[i];
					array[i].right.left = array[i];
					if (array[i].key < min.key)
					{
						min = array[i];
					}
				}
				else
				{
					min = array[i];
				}
			}
		}
	}
protected void consolidate ( ) { int arraySize = size + 1 ; Node [ ] array = new Node [ arraySize ] ; for ( int i = 0 ; i < arraySize ; i ++ ) { array [ i ] = null ; } int numRoots = 0 ; Node x = min ; if ( x != null ) { numRoots ++ ; x = x . right ; while ( x != min ) { numRoots ++ ; x = x . right ; } } while ( numRoots > 0 ) { int d = x . degree ; Node next = x . right ; while ( array [ d ] != null ) { Node y = array [ d ] ; if ( x . key > y . key ) { Node temp = y ; y = x ; x = temp ; } link ( y , x ) ; array [ d ] = null ; d ++ ; } array [ d ] = x ; x = next ; numRoots -- ; } min = null ; for ( int i = 0 ; i < arraySize ; i ++ ) { if ( array [ i ] != null ) { if ( min != null ) { array [ i ] . left . right = array [ i ] . right ; array [ i ] . right . left = array [ i ] . left ; array [ i ] . left = min ; array [ i ] . right = min . right ; min . right = array [ i ] ; array [ i ] . right . left = array [ i ] ; if ( array [ i ] . key < min . key ) { min = array [ i ] ; } } else { min = array [ i ] ; } } } }
Consolidates the trees in the heap by joining trees of equal degree until
 there are no more trees of equal degree in the root list.
Consolidates the trees in the heap by joining trees of equal degree until there are no more trees of equal degree in the root list .
// Initialize degree array // Find the number of root nodes. // For each node in root list do... // Access this node's degree.. // ..and see if there's another of the same degree. // There is, make one of the nodes a child of the other. // Do this based on the key value. // Node y disappears from root list. // We've handled this degree, go to next one. // Save this node for later when we might encounter another // of the same degree. // Move forward through list. // Set min to null (effectively losing the root list) and // reconstruct the root list from the array entries in array[]. // We've got a live one, add it to root list. // First remove node from root list. // Now add to root list, again. // Check if this is a new min.