Fibonacci Heaps: Motivation and Structure
Motivation
Dijkstra’s algorithm with a binary heap runs in . With a Fibonacci heap, the running time drops to , which is better when is super-linear in (i.e. for dense graphs). The critical improvement: decrease-key costs in a binary heap but only amortised in a Fibonacci heap.
Dijkstra calls insert times, extract-min times, and decrease-key times. The per-operation costs determine overall complexity:
| Operation | Binary Heap | Fibonacci Heap |
|---|---|---|
insert | amortised | |
extract-min | amortised | |
decrease-key | amortised | |
| Dijkstra total |
FibHeaps also support destructive-union (merge two heaps) in amortised time, versus for binary heaps.
Structure Overview
A Fibonacci heap is a collection of min-heap-ordered trees. This is similar to a binomial heap but the structure is maintained more lazily: rather than enforcing the binomial shape at every step, violations are allowed to accumulate and are cleaned up only during extract-min.
Root List
The trees are held in a circular, doubly linked list called the root list. There is no ordering amongst the roots; any root can be the minimum. A min pointer always tracks the current minimum root, maintained at .
Node Attributes
Each node stores eight fields:
- key — the priority value (duplicates permitted)
- payload — the data associated with the key
- left — pointer to left sibling
- right — pointer to right sibling
- parent — pointer to parent (NIL for root nodes)
- child — pointer to any one child (NIL if no children)
- degree — number of immediate children
- marked — boolean: has this node lost a child since it became a child of its current parent?
Children are held in unordered, circular, doubly linked lists (same as the root list). A pointer to a child node gives access to its entire sibling list; the exact position within the list does not matter because the lists are unordered.
The Fibonacci Heap Handle
A Fibonacci heap reference is a 2-tuple (min_ptr, n) where min_ptr points to the node containing the current minimum key and n is the total number of keys present.
Key Structural Rules
- Nodes in the root list are never marked.
- If a node’s key is decreased below its parent’s key (violating heap order), it is cut from its parent and moved to the root list. Its parent becomes marked (or, if already marked, is itself cut — the cascading cut).
- Consolidation (merging trees of equal degree) is performed only during
extract-min, bringing the root list back to at most trees.
Worked Example: State After Insertions
Suppose we insert keys 5, 3, 7, 2, 4, 1, 6 in that order into an empty FibHeap. After all inserts (each just adds a singleton to the root list), the root list contains all seven nodes as singletons (all degree 0). The min pointer points to 1. No consolidation has occurred yet; that happens only on extract-min.
Root list: [1] <-> [6] <-> [4] <-> [2] <-> [7] <-> [3] <-> [5]
min_ptr -> 1
n = 7
Summary
| Property | Detail |
|---|---|
| Structure | Collection of min-heap-ordered trees |
| Root list | Circular doubly linked, unordered |
| Child lists | Circular doubly linked, unordered per node |
| Node fields | key, payload, left, right, parent, child, degree, marked |
| Min pointer | Direct pointer to minimum root, |
| Mark bit | Tracks whether node has lost a child since becoming a child |
| Key advantage | decrease-key in amortised |
| Lazy strategy | Work deferred to extract-min (consolidation) |