26 for (
unsigned short i = 0; i < graph->
num_nodes; i++) {
40 fprintf(stderr,
"Error: min_pos == -1\n");
44 in_heap[min_pos] =
false;
47 if(neigh != min_pos && in_heap[neigh]) {
49 if (weight < tree_nodes[neigh].value) {
50 fathers[neigh] = min_pos;
58 for(
unsigned short i = 0; i < graph->
num_nodes; i++){
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.
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 decrease_value(FibonacciHeap *heap, OrdTreeNode *node, double new_value)
Decrease the value of a Node in the Fibonacci Heap.
void add_edge(MST *tree, const Edge *edge)
Add an Edge to the MST.
void create_mst(MST *mst, const Node *nodes, unsigned short num_nodes)
Create a Minimum Spanning Tree from a set of Nodes.
void prim(const Graph *graph, MST *mst)
The Prim algorithm to find the Minimum Spanning Tree O(|E| + |V| log |V|)
The declaration of the functions needed to compute the MST with Prim's algorithm.
double weight
Weight of the Edge, 1 if the data_structures is not weighted.
The Fibonacci Heap datastructure as collection of Heap-ordered Trees.
unsigned short num_nodes
The number of Nodes in the Heap.
Edge edges_matrix[MAX_VERTEX_NUM][MAX_VERTEX_NUM]
Adjacency matrix of the Graph.
Node nodes[MAX_VERTEX_NUM]
Array of Nodes.
unsigned short num_nodes
Number of Nodes in the Graph.
Minimum Spanning Tree, or MST, and also a 1-Tree.
unsigned short num_edges
The number of Edges in the MST.
bool isValid
True if the MST has the correct number of Edges, false otherwise.
unsigned short num_neighbours
Number of neighbours of the Node.
unsigned short neighbours[MAX_VERTEX_NUM - 1]
Array of IDs of the Node's neighbors.
A Heap-ordered Tree Node where the key of the parent is <= the key of its children.