20 for (
unsigned short i = 0; i < num_nodes; i++) {
21 if (i != candidateId) {
34 for (
unsigned short i = 0; i < num_nodes; i++) {
62 }
else if (set1_root->
rango < set2_root->
rango) {
73 for (
unsigned short i = 0; i < forest->
num_sets; i++) {
80 printf(
"Parent: NULL, ");
82 printf(
"Rango: %d, ", set.
rango);
void merge(Set *set1, Set *set2)
Merge two Sets in the Forest if they are not already in the same Set.
Set * find(Set *set)
Find the root of a Set.
void create_forest(Forest *forest, const Node *nodes, unsigned short num_nodes)
Create a new Forest with n Sets, each Set containing a Node, without constraints.
void create_forest_constrained(Forest *forest, const Node *nodes, unsigned short num_nodes, unsigned short candidateId)
Create a new Forest with n Sets, each Set containing a Node, with constraints.
void print_forest(const Forest *forest)
Print all the Forest.
This file contains the declaration of the Merge-Find Set datastructure for the Minimum Spanning Tree ...
A Forest is a list of Sets.
Set sets[MAX_VERTEX_NUM]
Array of Sets.
unsigned short num_sets
Number of Sets in the Forest.
unsigned short positionInGraph
Position of the Node in the list of Nodes of the Graph, i.e. its unique ID.
A Set is a node in the Forest.
struct Set * parentSet
Pointer to the parent Set in a tree representation of the Forest.
unsigned short num_in_forest
Number of the position of the Set in the Forest.
unsigned short rango
Rank of the Set, used to optimize the find operation.