Fibonacci heap implementation. More...
#include <ogdf/basic/heap/FibonacciHeap.h>
Inheritance diagram for ogdf::FibonacciHeap< T, C >:Public Member Functions | |
| FibonacciHeap (const C &cmp=C(), int initialSize=-1) | |
| Creates empty Fibonacci heap. More... | |
| virtual | ~FibonacciHeap () |
| Destructs the heap. More... | |
| void | decrease (FibonacciHeapNode< T > *heapNode, const T &value) override |
Decreases value of the given heapNode to value. More... | |
| void | merge (FibonacciHeap< T, C > &other) override |
Merges in values of other heap. More... | |
| void | pop () override |
| Removes the top element from the heap. More... | |
| FibonacciHeapNode< T > * | push (const T &value) override |
Inserts a new node with given value into a heap. More... | |
| const T & | top () const override |
| Returns reference to the top element in the heap. More... | |
| const T & | value (FibonacciHeapNode< T > *heapNode) const override |
| Returns the value of the node. More... | |
Public Member Functions inherited from ogdf::HeapBase< FibonacciHeap< T, C >, FibonacciHeapNode< T >, T, C > | |
| HeapBase (C const &comp=C()) | |
| virtual const C & | comparator () const |
| Returns the comparator used to sort the values in the heap. More... | |
| virtual void | decrease (Handle handle, const T &value)=0 |
| Decreases a single value. More... | |
| virtual const T & | value (const Handle handle) const=0 |
| Returns the value of that handle. More... | |
Private Types | |
| using | base_type = HeapBase< FibonacciHeap< T, C >, FibonacciHeapNode< T >, T, C > |
Private Member Functions | |
| void | compress () |
| Reduces number of trees inside a heap by linking ones with same degree. More... | |
| void | detach (FibonacciHeapNode< T > *heapNode) |
Detaches given heapNode from its list and makes it self-circulate. More... | |
| void | link (FibonacciHeapNode< T > *root, FibonacciHeapNode< T > *child) |
Makes child node a child of root node. More... | |
| void | merge (FibonacciHeapNode< T > *other) |
Merges other list into current heap list. More... | |
| void | release (FibonacciHeapNode< T > *heapNode) |
Recursively releases memory starting at heapNode. More... | |
| void | remove () |
| Removes minimal tree and moves its children to tree list. More... | |
| void | restore (FibonacciHeapNode< T > *heapNode) |
Restores heap ordering in heapNode by making (cascade) cut. More... | |
| void | splice (FibonacciHeapNode< T > *target, FibonacciHeapNode< T > *heapNode) |
Moves heapNode from its list to the target list. More... | |
Private Attributes | |
| FibonacciHeapNode< T > * | m_knot |
| Used for efficient tree list manipulation. More... | |
| FibonacciHeapNode< T > * | m_minimal |
| Handle to the tree with lowest root priority. More... | |
| std::array< FibonacciHeapNode< T > *, sizeof(size_t) *8 > | m_ranked |
| Used to compress trees. More... | |
Additional Inherited Members | |
Public Types inherited from ogdf::HeapBase< FibonacciHeap< T, C >, FibonacciHeapNode< T >, T, C > | |
| using | Handle = FibonacciHeapNode< T > * |
| The type of handle used to identify stored values. More... | |
Fibonacci heap implementation.
This implementation is based on Wikipedia article, original paper by Fredman and Tarjan and borrows some ideas from: http://www.cs.princeton.edu/~wayne/cs423/fibonacci/FibonacciHeapAlgorithm.html
| T | Denotes value type of inserted elements. |
| C | Denotes comparison functor determining value ordering. |
Definition at line 87 of file FibonacciHeap.h.
|
private |
Definition at line 90 of file FibonacciHeap.h.
|
explicit |
Creates empty Fibonacci heap.
| cmp | Comparison functor determining value ordering. |
| initialSize | ignored by this implementation. |
Definition at line 189 of file FibonacciHeap.h.
|
virtual |
Destructs the heap.
If the heap is not empty, destructors of contained elements are called and used storage is deallocated.
Definition at line 197 of file FibonacciHeap.h.
|
inlineprivate |
Reduces number of trees inside a heap by linking ones with same degree.
Definition at line 317 of file FibonacciHeap.h.
|
override |
Decreases value of the given heapNode to value.
Behaviour of this function is undefined if node does not belong to a the heap or new value is greater than old one.
| heapNode | A node for which the value is to be decreased. |
| value | A new value for the node. |
Definition at line 269 of file FibonacciHeap.h.
|
inlineprivate |
Detaches given heapNode from its list and makes it self-circulate.
Definition at line 366 of file FibonacciHeap.h.
|
inlineprivate |
Makes child node a child of root node.
Definition at line 349 of file FibonacciHeap.h.
|
overridevirtual |
Merges in values of other heap.
After merge other heap becomes empty and is valid for further usage.
| other | A heap to be merged in. |
Reimplemented from ogdf::HeapBase< FibonacciHeap< T, C >, FibonacciHeapNode< T >, T, C >.
Definition at line 281 of file FibonacciHeap.h.
|
inlineprivate |
Merges other list into current heap list.
Definition at line 376 of file FibonacciHeap.h.
|
overridevirtual |
Removes the top element from the heap.
Behaviour of this function is undefined if the heap is empty.
Implements ogdf::HeapBase< FibonacciHeap< T, C >, FibonacciHeapNode< T >, T, C >.
Definition at line 243 of file FibonacciHeap.h.
|
overridevirtual |
Inserts a new node with given value into a heap.
| value | A value to be inserted. |
Implements ogdf::HeapBase< FibonacciHeap< T, C >, FibonacciHeapNode< T >, T, C >.
Definition at line 229 of file FibonacciHeap.h.
|
private |
Recursively releases memory starting at heapNode.
Definition at line 204 of file FibonacciHeap.h.
|
inlineprivate |
Removes minimal tree and moves its children to tree list.
Definition at line 299 of file FibonacciHeap.h.
|
inlineprivate |
Restores heap ordering in heapNode by making (cascade) cut.
Definition at line 398 of file FibonacciHeap.h.
|
inlineprivate |
Moves heapNode from its list to the target list.
Definition at line 386 of file FibonacciHeap.h.
|
inlineoverridevirtual |
Returns reference to the top element in the heap.
Implements ogdf::HeapBase< FibonacciHeap< T, C >, FibonacciHeapNode< T >, T, C >.
Definition at line 222 of file FibonacciHeap.h.
|
inlineoverride |
Returns the value of the node.
| heapNode | The nodes handle |
Definition at line 154 of file FibonacciHeap.h.
|
private |
Used for efficient tree list manipulation.
Definition at line 162 of file FibonacciHeap.h.
|
private |
Handle to the tree with lowest root priority.
Definition at line 160 of file FibonacciHeap.h.
|
private |
Used to compress trees.
Definition at line 165 of file FibonacciHeap.h.