naev 0.12.5
union_find.c File Reference

Implements ye olde disjoint-set-forest data structure. More...

#include "union_find.h"
#include "array.h"
Include dependency graph for union_find.c:

Go to the source code of this file.

Functions

void unionfind_init (UnionFind *uf, int n)
 Creates a UnionFind structure on {0, ..., n}.
void unionfind_free (UnionFind *uf)
 Frees resources associated with uf.
void unionfind_union (UnionFind *uf, int x, int y)
 Declares x and y to be in the same subset.
int unionfind_find (UnionFind *uf, int x)
 Finds the designated representative of the subset containing x.
int * unionfind_findall (UnionFind *uf)
 Returns a designated representative of each subset in an array (array.h).

Detailed Description

Implements ye olde disjoint-set-forest data structure.

Definition in file union_find.c.

Function Documentation

◆ unionfind_find()

int unionfind_find ( UnionFind * uf,
int x )

Finds the designated representative of the subset containing x.

Definition at line 48 of file union_find.c.

◆ unionfind_findall()

int * unionfind_findall ( UnionFind * uf)

Returns a designated representative of each subset in an array (array.h).

Definition at line 57 of file union_find.c.

◆ unionfind_free()

void unionfind_free ( UnionFind * uf)

Frees resources associated with uf.

Definition at line 25 of file union_find.c.

◆ unionfind_init()

void unionfind_init ( UnionFind * uf,
int n )

Creates a UnionFind structure on {0, ..., n}.

Definition at line 14 of file union_find.c.

◆ unionfind_union()

void unionfind_union ( UnionFind * uf,
int x,
int y )

Declares x and y to be in the same subset.

Definition at line 34 of file union_find.c.