A C/C++ implementation of union by rank and find with path compression.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.md
union_find.cc

README.md

union-find

A C/C++ implementation of union by rank and find with path compression. The operations are fast and the implementation uses one array only. Applications include connectivity tests and finding minimum spanning trees (to name a few).

API

  • init(); // Initialize module
  • int root(int x); // Returns the representative of the disjoint set containing x
  • void join(int x, int y); // Unify the sets containing x and y