A Union/Find data structure for maintaining disjoint sets. More...
#include <ogdf/basic/DisjointSets.h>
Public Member Functions | |
DisjointSets (const DisjointSets &)=delete | |
DisjointSets (int maxNumberOfElements=(1<< 15)) | |
Creates an empty DisjointSets structure. | |
~DisjointSets () | |
int | find (int set) |
Returns the id of the largest superset of set and compresses the path according to CompressionOptions. | |
int | getNumberOfElements () |
Returns the current number of elements. | |
int | getNumberOfSets () |
Returns the current number of disjoint sets. | |
int | getRepresentative (int set) const |
Returns the id of the largest superset of set . | |
void | init () |
Resets the DisjointSets structure to be empty, preserving the previous value of maxNumberOfElements. | |
void | init (int maxNumberOfElements) |
Resets the DisjointSets structure to be empty, also changing the expected number of elements. | |
int | link (int set1, int set2) |
Unions set1 and set2 . | |
int | makeSet () |
Initializes a singleton set. | |
DisjointSets & | operator= (const DisjointSets &)=delete |
bool | quickUnion (int set1, int set2) |
Unions the maximal disjoint sets containing set1 and set2 . | |
Private Attributes | |
int | m_maxNumberOfElements |
Maximum number of elements (array size) adjusted dynamically. | |
int | m_numberOfElements |
Current number of elements. | |
int | m_numberOfSets |
Current number of disjoint sets. | |
int * | m_parameters |
Maps set id to rank/size. | |
int * | m_parents |
Maps set id to parent set id. | |
int * | m_siblings |
Maps set id to sibling set id. | |
A Union/Find data structure for maintaining disjoint sets.
Definition at line 89 of file DisjointSets.h.
|
inlineexplicit |
Creates an empty DisjointSets structure.
maxNumberOfElements | Expected number of Elements. |
Definition at line 145 of file DisjointSets.h.
|
delete |
|
inline |
Definition at line 154 of file DisjointSets.h.
|
private |
Definition at line 374 of file DisjointSets.h.
|
private |
Definition at line 365 of file DisjointSets.h.
|
private |
Definition at line 310 of file DisjointSets.h.
|
private |
Definition at line 324 of file DisjointSets.h.
|
private |
Definition at line 336 of file DisjointSets.h.
|
private |
Definition at line 350 of file DisjointSets.h.
|
inline |
Returns the id of the largest superset of set
and compresses the path according to CompressionOptions.
set | Set. |
set
is a non negative properly initialized id. Definition at line 188 of file DisjointSets.h.
|
inline |
Returns the current number of elements.
Definition at line 283 of file DisjointSets.h.
|
inline |
Returns the current number of disjoint sets.
Definition at line 280 of file DisjointSets.h.
|
inline |
Returns the id of the largest superset of set
.
set | Set. |
set
is a non negative properly initialized id. Definition at line 200 of file DisjointSets.h.
|
inline |
Resets the DisjointSets structure to be empty, preserving the previous value of maxNumberOfElements.
Definition at line 167 of file DisjointSets.h.
|
inline |
Resets the DisjointSets structure to be empty, also changing the expected number of elements.
Definition at line 161 of file DisjointSets.h.
|
private |
Definition at line 554 of file DisjointSets.h.
|
private |
Definition at line 602 of file DisjointSets.h.
|
private |
Definition at line 566 of file DisjointSets.h.
|
private |
Definition at line 585 of file DisjointSets.h.
|
inline |
Unions set1
and set2
.
set1
and set2
are maximal disjoint sets. Definition at line 255 of file DisjointSets.h.
|
inlineprivate |
Unions set1
and set2
w/o decreasing the numberOfSets.
set1
and set2
are maximal disjoint sets. Definition at line 291 of file DisjointSets.h.
|
inline |
Initializes a singleton set.
Definition at line 213 of file DisjointSets.h.
|
delete |
|
private |
Definition at line 381 of file DisjointSets.h.
|
private |
Definition at line 437 of file DisjointSets.h.
|
private |
Use path splitting to compress the path of set1 and get the root
Redirect all nodes with smaller indices on the path of set2 to the root
Definition at line 467 of file DisjointSets.h.
|
private |
Definition at line 399 of file DisjointSets.h.
|
private |
Definition at line 520 of file DisjointSets.h.
|
inline |
Unions the maximal disjoint sets containing set1
and set2
.
set1
and set2
were disjoint und joined correctly. False otherwise. Definition at line 269 of file DisjointSets.h.
|
private |
Maximum number of elements (array size) adjusted dynamically.
Definition at line 104 of file DisjointSets.h.
|
private |
Current number of elements.
Definition at line 103 of file DisjointSets.h.
|
private |
Current number of disjoint sets.
Definition at line 102 of file DisjointSets.h.
|
private |
Maps set id to rank/size.
Definition at line 109 of file DisjointSets.h.
|
private |
Maps set id to parent set id.
Definition at line 108 of file DisjointSets.h.
|
private |
Maps set id to sibling set id.
Definition at line 110 of file DisjointSets.h.