naev 0.12.5
union_find.h
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
4#pragma once
5
7typedef struct UnionFind_ {
8 int *parent;
9 int *rank;
10} UnionFind;
11
12void unionfind_init( UnionFind *uf, int n );
13void unionfind_free( UnionFind *uf );
14void unionfind_union( UnionFind *uf, int x, int y );
15int unionfind_find( UnionFind *uf, int x );
Disjoint set forest on {0, .., n-1}.
Definition union_find.h:7
int * parent
Definition union_find.h:8
int * rank
Definition union_find.h:9
int * unionfind_findall(UnionFind *uf)
Returns a designated representative of each subset in an array (array.h).
Definition union_find.c:57
int unionfind_find(UnionFind *uf, int x)
Finds the designated representative of the subset containing x.
Definition union_find.c:48
void unionfind_init(UnionFind *uf, int n)
Creates a UnionFind structure on {0, ..., n}.
Definition union_find.c:14
void unionfind_union(UnionFind *uf, int x, int y)
Declares x and y to be in the same subset.
Definition union_find.c:34
void unionfind_free(UnionFind *uf)
Frees resources associated with uf.
Definition union_find.c:25