The Original CHomP Software
|
This template contains the definition of a Fibonacci heap that can be used as an efficient priority queue, for example, in the Dijxtra graph algorithm. More...
#include <fibheap.h>
Classes | |
struct | Node |
The structure that holds a graph node for the graph representation of a Fibonacci heap. More... | |
Public Types | |
typedef int_t | NodePtr |
The type of a pointer to a node in the Fibonacci heap. More... | |
Public Member Functions | |
FibonacciHeap (int_t maxSize=0) | |
The constructor of an empty Fibonacci heap. More... | |
~FibonacciHeap () | |
The destructor of a Fibonacci heap. More... | |
int_t | Insert (const element &value) |
Inserts an element into the heap. More... | |
int_t | Minimum () const |
Returns the number of the node that contains the minimum. More... | |
const element & | Value (int_t number) const |
Returns the value of the node with the given number. More... | |
element | ExtractMinimum () |
Extracts the minimum from the heap. More... | |
void | DecreaseKey (int_t number, const element &value) |
Decreases the key of the element identified by the given number to the new value. More... | |
void | Delete (int_t number) |
Removes the element identified by the given number from the heap. More... | |
Static Public Attributes | |
static const int_t | NullPtr |
The value used for a NULL pointer. More... | |
Private Member Functions | |
FibonacciHeap (const FibonacciHeap< element > &) | |
The copy constructor is not allowed. More... | |
FibonacciHeap< element > & | operator= (const FibonacciHeap< element > &) |
The assignment operator is not allowed. More... | |
void | Consolidate () |
Consolidates the Fibonacci heap by joining roots of equal degree. More... | |
void | Cut (const typename FibonacciHeap< element >::NodePtr &x, const typename FibonacciHeap< element >::NodePtr &y) |
Cuts the tree. More... | |
void | CascadingCut (typename FibonacciHeap< element >::NodePtr y) |
Does a cascading cut of the tree. More... | |
void | showGraph (std::ostream &out, int_t depth, const typename FibonacciHeap< element >::NodePtr &x) const |
Shows a graph starting at the given node using DFS. More... | |
Private Attributes | |
NodePtr | minRoot |
A pointer to the minimal element in the list of roots. More... | |
int_t | nodeCount |
The total number of nodes inserted to the heap and allocated in the multitable "nodes". More... | |
multitable< Node > | nodes |
The array of nodes which hold the elements inserted to the heap in this order. More... | |
element | minValue |
The minimal value that ever appeared in the heap. More... | |
multitable< NodePtr > | auxArray |
An auto-expandable array used by the "Consolidate" procedure. More... | |
int_t | arrayPrepared |
The size of the prepared data in the array. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &out, const FibonacciHeap< element > &h) |
Operator << shows the heap to the output stream. More... | |
This template contains the definition of a Fibonacci heap that can be used as an efficient priority queue, for example, in the Dijxtra graph algorithm.
Note that if the "Delete" function is used then the elements must support the arithmetic subtraction of 1 to create a value that is strictly smaller than the given one (like the integers). This is a very specialized implementation which does not support the "Union" operation. Moreover, the "Delete" or "ExtractMinimum" don't actually free the memory used by the deleted elements in this implementation. See the description of the functions in this class for more information.
typedef int_t chomp::homology::FibonacciHeap< element >::NodePtr |
|
inline |
The constructor of an empty Fibonacci heap.
The maximal number of elements may be given if it is known.
Definition at line 260 of file fibheap.h.
|
inline |
The destructor of a Fibonacci heap.
Definition at line 274 of file fibheap.h.
|
inlineprivate |
|
inlineprivate |
Does a cascading cut of the tree.
Definition at line 609 of file fibheap.h.
|
inlineprivate |
Consolidates the Fibonacci heap by joining roots of equal degree.
Definition at line 394 of file fibheap.h.
|
inlineprivate |
Cuts the tree.
Definition at line 570 of file fibheap.h.
|
inline |
Decreases the key of the element identified by the given number to the new value.
Definition at line 633 of file fibheap.h.
|
inline |
Removes the element identified by the given number from the heap.
Definition at line 666 of file fibheap.h.
|
inline |
Extracts the minimum from the heap.
The element is removed from the heap and its value is returned.
Definition at line 513 of file fibheap.h.
|
inline |
Inserts an element into the heap.
Returns the number of the node which is to be used for decreasing the key or removing this element from the heap. The numbers are returned in the ascending order, starting at 0.
Definition at line 302 of file fibheap.h.
|
inline |
|
inlineprivate |
|
private |
Shows a graph starting at the given node using DFS.
Definition at line 230 of file fibheap.h.
|
inline |
|
friend |
Operator << shows the heap to the output stream.
Essentially, this might be useful for debugging purposes only.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
The array of nodes which hold the elements inserted to the heap in this order.
The indices of these elements are returned while inserting them to the heap and can be used to access these nodes directly, e.g., in order to decrease their keys or delete them from the heap.
|
static |