c++stldisjoint-setsunion-find

Is the Union-Find (or Disjoint Set) data structure in STL?


I would have expected such a useful data structure to be included in the C++ Standard Library but I can't seem to find it.


Solution

  • It is not, but there is one in boost: http://www.boost.org/doc/libs/1_64_0/libs/disjoint_sets/disjoint_sets.html, so if you want an off-the-shelf implementation I'd recommend this.