Disjoint-set implementation. More...
#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
#include "disjoint_set.h"
#include "debug.h"
Go to the source code of this file.
Functions | |
static void | link_sets (disjoint_set_t *ds, size_t set1, size_t set2) |
Links two sets. | |
static size_t | find_set (disjoint_set_t *ds, size_t id) |
Finds the set containing an element. | |
int | disjoint_set_new (disjoint_set_t **ds, size_t size) |
Creates a new disjoint-set. | |
int | disjoint_set_free (disjoint_set_t *ds) |
Frees a disjoint-set. | |
int | disjoint_set_union (disjoint_set_t *ds, size_t elem1, size_t elem2) |
Unites the sets that contain two elements. | |
int | disjoint_set_find (disjoint_set_t *ds, size_t *set, size_t elem) |
Finds the set containing an element. |
Disjoint-set implementation.
Definition in file disjoint_set.c.
static size_t find_set | ( | disjoint_set_t * | ds, | |
size_t | id | |||
) | [static] |
Finds the set containing an element.
ds | the disjoint_set_t to search in | |
id | the id of the element to find the set of |
Definition at line 71 of file disjoint_set.c.
Referenced by disjoint_set_find().
static void link_sets | ( | disjoint_set_t * | ds, | |
size_t | set1, | |||
size_t | set2 | |||
) | [static] |
Links two sets.
ds | the disjoint_set_t the sets belong to | |
set1 | the id (root) of set1 | |
set2 | the id (root) of set2 |
Definition at line 49 of file disjoint_set.c.
Referenced by disjoint_set_union().