96 if(node1->
key == node2->
key){
116 int dimension = ((int) ceil(log(heap->
num_nodes) / log(2))) + 2;
119 for (
int i = 0; i < dimension; i++) {
120 degree_list[i] = NULL;
126 for (
int i = 0; i < num_it; i++) {
131 while(degree_list[deg]!=NULL){
137 deg_i_node = same_deg_node;
138 same_deg_node = temp;
144 degree_list[deg] = NULL;
147 degree_list[deg] = deg_i_node;
152 for (
int i = 0; i < dimension; i++) {
153 if(degree_list[i]!=NULL){
186 for (
unsigned short i = 0; i < num_children; i++) {
191 if(num_children - i == 1){
287 cut(heap, node, parent);
295 if(new_value > node->
value){
296 fprintf(stderr,
"Error: new value is greater than current value\n");
300 node->
value = new_value;
void link_trees(FibonacciHeap *heap, OrdTreeNode *child, OrdTreeNode *father)
void insert_node(FibonacciHeap *heap, OrdTreeNode *node)
Insert a Node in the Fibonacci Heap.
void create_insert_node(FibonacciHeap *heap, OrdTreeNode *node, unsigned short key, double value)
A wrapper function to create a Node and insert it in the Fibonacci Heap.
void consolidate(FibonacciHeap *heap)
static void cascading_cut(FibonacciHeap *heap, OrdTreeNode *node)
int extract_min(FibonacciHeap *heap)
Extract the minimum Node from the Fibonacci Heap.
void create_fibonacci_heap(FibonacciHeap *heap)
Create an empty Fibonacci Heap.
void delete_node(FibonacciHeap *heap, OrdTreeNode *node)
static void cut(FibonacciHeap *heap, OrdTreeNode *node, OrdTreeNode *parent)
void create_node(OrdTreeNode *node, unsigned short key, double value)
Create a Node with a given key and value.
void swap_roots(FibonacciHeap *heap, OrdTreeNode *node1, OrdTreeNode *node2)
void decrease_value(FibonacciHeap *heap, OrdTreeNode *node, double new_value)
Decrease the value of a Node in the Fibonacci Heap.
This file contains the declaration of the Fibonacci Heap datastructure for the Minimum Spanning Tree ...
The Fibonacci Heap datastructure as collection of Heap-ordered Trees.
OrdTreeNode * min_root
The root of the Heap-ordered Tree with the minimum value.
OrdTreeNode * tail_tree_list
The root of the tail Tree in the Fibonacci Heap.
unsigned short num_trees
The number of Trees in the Heap.
OrdTreeNode * head_tree_list
The root of the head Tree in the Fibonacci Heap.
unsigned short num_nodes
The number of Nodes in the Heap.
A Heap-ordered Tree Node where the key of the parent is <= the key of its children.
struct OrdTreeNode * right_sibling
The right sibling of the Node.
bool marked
True if the Node has lost a child, false otherwise.
unsigned short num_children
The number of children of the Node.
struct OrdTreeNode * head_child_list
The head of the list of children of the Node.
struct OrdTreeNode * left_sibling
The left sibling of the Node.
unsigned short key
The key of the Node.
bool is_root
True if the Node is a root, false otherwise.
struct OrdTreeNode * parent
The parent of the Node.
double value
The value of the Node.
struct OrdTreeNode * tail_child_list
The tail of the list of children of the Node.