Description Usage Arguments Value Examples
Decreases the key of a node in a heap and updates the complete
heap. The key is decreases from
a value to
a value by that moving the
node's position in the heap. If a node cannot uniquely be identified using
the to
key, a handle
needs to be given in addition.
1 2 3 4 5 6 7 | decrease_key(obj, from, to, handle)
## S4 method for signature 'heap,vector,vector,character'
decrease_key(obj, from, to, handle)
## S4 method for signature 'heap,vector,vector,missing'
decrease_key(obj, from, to)
|
obj |
a heap object |
from |
a key in the heap for which the node should be decreased |
to |
the new value of the heap |
handle |
the handle of the specific node that is decreased |
returns extracted handles and values from obj
1 2 3 4 5 6 7 8 9 10 11 | # decreases the key of a heap
f_heap <- fibonacci_heap("integer")
f_heap <- insert(f_heap, 1:5, letters[1:5])
peek(f_heap)
decrease_key(f_heap, 5L, -1L)
peek(f_heap)
hand <- handle(f_heap, value=letters[3])
decrease_key(f_heap, hand[[1]]$key, -2L)
peek(f_heap)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.