fibonacciheap v1.0.5
WARNING: This module is now deprecated. Please replace with @tyriar/fibonacci-heap
| Algorithm | clear | decreaseKey | delete | extractMinimum | findMinimum | insert | isEmpty | size | union |
|---|---|---|---|---|---|---|---|---|---|
| Fibonacci heap | Θ(1)* | Θ(1)* | O(log n)* | O(log n)* | Θ(1) | Θ(1) | Θ(1) | Θ(n) | Θ(1) |
* amortised
Installation
$ npm install fibonacciheapMethods
clear()Clears the heap's data, making it an empty heap.
decreaseKey(node, newKey)node: Node, the node to be decreased
newKey: number, the new key value
delete(node)node: Node, the node to remove from the heap
extractMinimum()Returns
Node, the node with the smallest key
findMinimum()Returns
Node, the node with the smallest key
insert(key, value)key: number,
value: object, any value associated with the node to insert
Returns
Node, the node that was inserted
isEmpty()Returns
boolean, true if the heap is empty
size() Returns
number, the amount of nodes in the heap
union(other)other: FibonacciHeap, the FibonacciHeap to union with this one
compare(a, b) a: Node, a node to compare
b: Node, a node to compare
Returns
number, 1 if
ahas a larger key thanb, -1 ifbhas a larger key thanaand 0 if they are equal
Running Tests
Install the development dependencies:
$ npm installThen run the tests:
$ npm testCode Coverage
Install the development dependencies:
$ npm installThen run coverage
$ npm run coverageView coverage reports
$ firefox coverage/lcov-report/index.htmlBrowser Bundle
$ npm run build