|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.neo4j.graphalgo.impl.util.FibonacciHeap<KeyType>
KeyType - The datatype to be stored in this heap.public class FibonacciHeap<KeyType>
At least a partial implementation of a Fibonacci heap (a priority heap). Almost all code is based on the chapter about Fibonacci heaps in the book "Introduction to Algorithms" by Cormen, Leiserson, Rivest and Stein (second edition, 2001). Amortized times for almost all operations are O(1). extractMin() runs in amortized time O(log n), which then a delete() based upon it also would. This Fibonacci heap can store any datatype, given by the KeyType parameter, all it needs is a comparator for that type. To achieve the stated running times, it is needed that this comparator can do comparisons in constant time (usually the case).
| Nested Class Summary | |
|---|---|
class |
FibonacciHeap.FibonacciHeapNode
One entry in the fibonacci heap is stored as an instance of this class. |
| Constructor Summary | |
|---|---|
FibonacciHeap(Comparator<KeyType> keyComparator)
|
|
| Method Summary | |
|---|---|
protected void |
cascadingCut(FibonacciHeap.FibonacciHeapNode y)
Internal helper function. |
protected void |
consolidate()
Internal helper function. |
protected void |
cut(FibonacciHeap.FibonacciHeapNode x,
FibonacciHeap.FibonacciHeapNode y)
Internal helper function. |
void |
decreaseKey(FibonacciHeap.FibonacciHeapNode node,
KeyType newKey)
Raises the priority for an entry. |
KeyType |
extractMin()
This removes and returns the entry with the highest priority. |
FibonacciHeap.FibonacciHeapNode |
getMinimum()
|
FibonacciHeap.FibonacciHeapNode |
insert(KeyType key)
Inserts a new value into the heap. |
protected void |
insertInRootList(FibonacciHeap.FibonacciHeapNode fNode)
Internal helper function for moving nodes into the root list |
boolean |
isEmpty()
|
protected void |
link(FibonacciHeap.FibonacciHeapNode y,
FibonacciHeap.FibonacciHeapNode x)
Internal helper function. |
int |
size()
|
void |
union(FibonacciHeap<KeyType> other)
Creates the union of two heaps by absorbing the other into this one. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FibonacciHeap(Comparator<KeyType> keyComparator)
| Method Detail |
|---|
public boolean isEmpty()
public int size()
public FibonacciHeap.FibonacciHeapNode getMinimum()
protected void insertInRootList(FibonacciHeap.FibonacciHeapNode fNode)
public FibonacciHeap.FibonacciHeapNode insert(KeyType key)
key - the value to be inserted.
public void union(FibonacciHeap<KeyType> other)
public KeyType extractMin()
protected void consolidate()
protected void link(FibonacciHeap.FibonacciHeapNode y,
FibonacciHeap.FibonacciHeapNode x)
public void decreaseKey(FibonacciHeap.FibonacciHeapNode node,
KeyType newKey)
node - The entry to recieve a higher priority.newKey - The new value.
protected void cut(FibonacciHeap.FibonacciHeapNode x,
FibonacciHeap.FibonacciHeapNode y)
protected void cascadingCut(FibonacciHeap.FibonacciHeapNode y)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||