Gromacs
2025-dev-20241003-bd59e46
|
#include <gromacs/trajectoryanalysis/modules/unionfind.h>
Extension of UnionFind that supports non-consecutive integer indices as items.
Sometimes, it is more convenient to operate on a set of integers that do not start at zero and are not consecutive as UnionFind expects. This class implements a mapping on top of UnionFind such that this is possible.
The current implementation assumes that the indices are bounded between zero and some reasonably small integer, i.e., the memory usage depends on the largest index number, not just on the number of items.
Public Member Functions | |
void | initWithGroupIndices (ArrayRef< const int > indices) |
Initializes the finder with indices. More... | |
int | representativeValue (int group) |
Returns a reprensetative value for an item that is unique for each set. More... | |
void | mergeGroups (int group1, int group2) |
Merges sets that contain two given items. More... | |
std::vector< int > | allSizes () |
Returns the sizes of all sets (in arbitrary order). More... | |
|
inline |
Returns the sizes of all sets (in arbitrary order).
If there were multiple identical indices passed to initWithGroupIndices(), these are only counted as one when computing the sizes.
|
inline |
Initializes the finder with indices.
The size of indices
sets the number of input items, and each unique value in indices
maps to a single internal item. If multiple indices are the same, then these items are considered equivalent.
|
inline |
Merges sets that contain two given items.
If the items are already in the same set, nothing happens. Each input value should be one of the values that were passed in as an index to initWithGroupIndices().
|
inline |
Returns a reprensetative value for an item that is unique for each set.
group
should be one of the values that were passed in as an index to initWithGroupIndices(). The return value is an internal index that has no simple relation to the input indices.