|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
46 template<
typename,
typename>
73 template<
typename T,
typename C = std::less<T>>
84 explicit BinomialHeap(
const C& cmp = C(),
int initialSize = -1);
95 const T&
top()
const override;
155 template<
typename T,
typename C>
159 template<
typename T,
typename C>
165 template<
typename T,
typename C>
167 while (heapNode !=
nullptr) {
168 release(heapNode->
child);
176 template<
typename T,
typename C>
180 if (this->comparator()(it->value, min->
value)) {
188 template<
typename T,
typename C>
196 template<
typename T,
typename C>
200 while (curr->
next !=
nullptr) {
201 if (this->comparator()(curr->
next->value, min->value)) {
211 minPrev->next = min->next;
216 while (child !=
nullptr) {
218 child->next = reversed;
226 template<
typename T,
typename C>
231 heapNode->
value = value;
233 while (heapNode->
parent !=
nullptr
234 && this->comparator()(heapNode->
value, heapNode->
parent->value)) {
235 std::swap(heapNode->
value, heapNode->
parent->value);
236 heapNode = heapNode->
parent;
240 template<
typename T,
typename C>
246 template<
typename T,
typename C>
260 while (b !=
nullptr) {
261 if (a->
next ==
nullptr) {
281 template<
typename T,
typename C>
283 m_root =
join(m_root, other);
284 if (m_root ==
nullptr) {
289 while (next !=
nullptr) {
290 if (curr->rank != next->rank || (next->next !=
nullptr && next->next->rank == curr->rank)) {
297 if (this->comparator()(curr->value, next->value)) {
298 curr->next = next->next;
300 }
else if (prev ==
nullptr) {
313 template<
typename T,
typename C>
317 parent->
child = child;
The namespace for all OGDF objects.
const T & value(BinomialHeapNode< T > *heapNode) const override
Returns the value of the node.
Common interface for all heap classes.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
void decrease(BinomialHeapNode< T > *heapNode, const T &value) override
Decreases value of the given heapNode to value.
size_t rank
Determines rank of a node.
BinomialHeapNode< T > * child
First child of the node.
const T & top() const override
Returns reference to the top element in the heap.
Binomial heap implementation.
static void release(BinomialHeapNode< T > *heapNode)
Releases memory occupied by list of heaps given as heapNode.
BinomialHeapNode< T > * push(const T &value) override
Inserts a new node with given value into a heap.
BinomialHeapNode< T > * join(BinomialHeapNode< T > *a, BinomialHeapNode< T > *b)
Joins heap lists a and b into single list sorted by the ranks.
BinomialHeapNode< T > * m_root
Root node of the heap.
virtual ~BinomialHeap()
Destructs the heap.
BinomialHeap(const C &cmp=C(), int initialSize=-1)
Creates empty binomial heap.
void join(Graph &G, node u, node v, sync_plan::PipeBij &bij, List< bool > *reverse_v=nullptr)
T value
Value contained in the node.
Interface for heap implementations.
BinomialHeapNode(const T &nodeValue)
Creates heap node with a given nodeValue.
Basic declarations, included by all source files.
void pop() override
Removes the top element from the heap.
static void link(BinomialHeapNode< T > *parent, BinomialHeapNode< T > *child)
Makes child node a child of parent node.
void merge(BinomialHeap< T, C > &other) override
Merges in values of other heap.
BinomialHeapNode< T > * next
Next sibling of the node.
BinomialHeapNode< T > * parent
Parent of the node.