lib: add `union_find`, a union–find algorithm with a disjoint-set data structure

Signed-off-by: Jean Privat <jean@pryen.org>