decrease-key

Decrease operation in fibonacci heap, boost

邮差的信 提交于 2020-01-06 00:01:28
问题 I'm trying to use in my implementation the fibonacci heap from boost but my program crashes, when I calling decrease function, this the example (W is a simple class): struct heap_data { boost::heap::fibonacci_heap<heap_data>::handle_type handle; W* payload; heap_data(W* w) { payload = w; } bool operator<(heap_data const & rhs) const { return payload->get_key() < rhs.payload->get_key(); } }; int main() { boost::heap::fibonacci_heap<heap_data> heap; vector<heap_data> A; for (int i = 0; i < 10;

Decrease operation in fibonacci heap, boost

别说谁变了你拦得住时间么 提交于 2020-01-06 00:01:12
问题 I'm trying to use in my implementation the fibonacci heap from boost but my program crashes, when I calling decrease function, this the example (W is a simple class): struct heap_data { boost::heap::fibonacci_heap<heap_data>::handle_type handle; W* payload; heap_data(W* w) { payload = w; } bool operator<(heap_data const & rhs) const { return payload->get_key() < rhs.payload->get_key(); } }; int main() { boost::heap::fibonacci_heap<heap_data> heap; vector<heap_data> A; for (int i = 0; i < 10;

How to implement O(logn) decrease-key operation for min-heap based Priority Queue?

依然范特西╮ 提交于 2019-11-28 03:48:17
I am working on an application that demonstrates the Djikstra's algorithm , and to use it, I need to restore the heap property when my elements' value is decreased. The problem regarding the complexity is that when the algorithm changes the value of an element, that element's index in the internal structure (heap in this case) used for the priority queue is unknown . As such, I currently need to do an O(n) search, in order to recover the index, before I can perform an actual decrease-key on it. Moreover, I am not exactly sure about the actual code needed for the operation. I am using the D

How to implement O(logn) decrease-key operation for min-heap based Priority Queue?

瘦欲@ 提交于 2019-11-27 05:10:17
问题 I am working on an application that demonstrates the Djikstra's algorithm , and to use it, I need to restore the heap property when my elements' value is decreased. The problem regarding the complexity is that when the algorithm changes the value of an element, that element's index in the internal structure (heap in this case) used for the priority queue is unknown . As such, I currently need to do an O(n) search, in order to recover the index, before I can perform an actual decrease-key on