public class mxFibonacciHeap
extends java.lang.Object
Modifier and Type | Class | Description |
---|---|---|
static class |
mxFibonacciHeap.Node |
Implements a node of the Fibonacci heap.
|
Modifier and Type | Field | Description |
---|---|---|
protected mxFibonacciHeap.Node |
min |
|
protected java.util.Map<java.lang.Object,mxFibonacciHeap.Node> |
nodes |
Maps from elements to nodes
|
protected int |
size |
Constructor | Description |
---|---|
mxFibonacciHeap() |
Modifier and Type | Method | Description |
---|---|---|
protected void |
cascadingCut(mxFibonacciHeap.Node y) |
Performs a cascading cut operation.
|
protected void |
consolidate() |
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.
|
protected void |
cut(mxFibonacciHeap.Node x,
mxFibonacciHeap.Node y) |
The reverse of the link operation: removes x from the child list of y.
|
void |
decreaseKey(mxFibonacciHeap.Node x,
double k) |
Decreases the key value for a heap node, given the new value to take on.
|
void |
delete(mxFibonacciHeap.Node x) |
Deletes a node from the heap given the reference to the node.
|
mxFibonacciHeap.Node |
getNode(java.lang.Object element,
boolean create) |
Returns the node that represents element.
|
void |
insert(mxFibonacciHeap.Node node,
double key) |
Inserts a new data element into the heap.
|
boolean |
isEmpty() |
Returns true if the queue is empty.
|
protected void |
link(mxFibonacciHeap.Node y,
mxFibonacciHeap.Node x) |
Make node y a child of node x.
|
mxFibonacciHeap.Node |
min() |
Returns the smallest element in the heap.
|
mxFibonacciHeap.Node |
removeMin() |
Removes the smallest element from the heap.
|
int |
size() |
Returns the size of the heap which is measured in the number of elements
contained in the heap.
|
static mxFibonacciHeap |
union(mxFibonacciHeap h1,
mxFibonacciHeap h2) |
Joins two Fibonacci heaps into a new one.
|
protected java.util.Map<java.lang.Object,mxFibonacciHeap.Node> nodes
protected mxFibonacciHeap.Node min
protected int size
public mxFibonacciHeap.Node getNode(java.lang.Object element, boolean create)
element
- the element whose node to findcreate
- whether to createpublic boolean isEmpty()
public void decreaseKey(mxFibonacciHeap.Node x, double k)
Running time: O(1) amortized
x
- Node whose value should be decreased.k
- New key value for node x.java.lang.IllegalArgumentException
- Thrown if k is larger than x.key value.public void delete(mxFibonacciHeap.Node x)
Running time: O(log n) amortized
x
- The node to remove from the heap.public void insert(mxFibonacciHeap.Node node, double key)
Running time: O(1) actual
node
- new node to insert into heapkey
- key value associated with data objectpublic mxFibonacciHeap.Node min()
Running time: O(1) actual
public mxFibonacciHeap.Node removeMin()
Running time: O(log n) amortized
public int size()
Running time: O(1) actual
public static mxFibonacciHeap union(mxFibonacciHeap h1, mxFibonacciHeap h2)
Running time: O(1) actual
h1
- The first heap.h2
- The second heap.protected void cascadingCut(mxFibonacciHeap.Node y)
Running time: O(log n); O(1) excluding the recursion
y
- The node to perform cascading cut on.protected void consolidate()
Running time: O(log n) amortized
protected void cut(mxFibonacciHeap.Node x, mxFibonacciHeap.Node y)
Running time: O(1)
x
- The child of y to be removed from y's child list.y
- The parent of x about to lose a child.protected void link(mxFibonacciHeap.Node y, mxFibonacciHeap.Node x)
Running time: O(1) actual
y
- The node to become child.x
- The node to become parent.Copyright (c) 2010-2017 Gaudenz Alder, JGraph Ltd. All rights reserved.