|
SNAP Library 2.4, Developer Reference
2015-05-11 19:40:56
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
Union Find class (Disjoint-set data structure). More...
#include <gbase.h>

Public Member Functions | |
| TInt & | Parent (const int &Key) |
| Returns the parent of element Key. More... | |
| TInt & | Rank (const int &Key) |
| Returns the rank of element Key. More... | |
| TUnionFind () | |
| TUnionFind (const int &ExpectKeys) | |
| Constructor that reserves enough memory for ExpectKeys elements. More... | |
| TUnionFind (const TUnionFind &UnionFind) | |
| TUnionFind & | operator= (const TUnionFind &UF) |
| int | Len () const |
| Returns the number of elements in the structure. More... | |
| bool | IsKey (const int &Key) const |
| Returns true if the structure contains element Key. More... | |
| int | GetKeyI (const int &KeyN) const |
| Returns the element KeyN. More... | |
| int | Find (const int &Key) |
| Returns the set that contains element Key. More... | |
| int | Add (const int &Key) |
| Adds an element Key to the structure. More... | |
| void | Union (const int &Key1, const int &Key2) |
| Merges sets with elements Key1 and Key2. More... | |
| bool | IsSameSet (const int &Key1, const int &Key2) |
| Returns true if elements Key1 and Key2 are in the same set. More... | |
| void | Dump () |
| Prints out the structure to standard output. More... | |
Private Attributes | |
| THash< TInt, TIntPr > | KIdSetH |
Union Find class (Disjoint-set data structure).
For more info see: http://en.wikipedia.org/wiki/Disjoint-set_data_structure).
|
inline |
|
inline |
|
inline |
Adds an element Key to the structure.
Definition at line 238 of file gbase.h.
References THash< TKey, TDat, THashFunc >::AddDat(), and KIdSetH.
Referenced by TSnap::TSnapDetail::TCNMQMatrix::Init().


| void TUnionFind::Dump | ( | ) |
Prints out the structure to standard output.
Definition at line 53 of file gbase.cpp.
References Find(), THash< TKey, TDat, THashFunc >::GetKey(), KIdSetH, and THash< TKey, TDat, THashFunc >::Len().

| int TUnionFind::Find | ( | const int & | Key | ) |
Returns the set that contains element Key.
Definition at line 23 of file gbase.cpp.
References Parent().
Referenced by TSnap::TSnapDetail::TCNMQMatrix::CmtyCMN(), Dump(), IsSameSet(), and Union().


|
inline |
Returns the element KeyN.
Definition at line 234 of file gbase.h.
References THash< TKey, TDat, THashFunc >::GetKey(), and KIdSetH.

|
inline |
Returns true if the structure contains element Key.
Definition at line 232 of file gbase.h.
References THash< TKey, TDat, THashFunc >::IsKey(), and KIdSetH.

|
inline |
Returns true if elements Key1 and Key2 are in the same set.
Definition at line 242 of file gbase.h.
References Find().

|
inline |
Returns the number of elements in the structure.
Definition at line 230 of file gbase.h.
References KIdSetH, and THash< TKey, TDat, THashFunc >::Len().

|
inline |
|
inline |
Returns the parent of element Key.
Definition at line 219 of file gbase.h.
References THash< TKey, TDat, THashFunc >::GetDat(), KIdSetH, and TPair< TVal1, TVal2 >::Val1.
Referenced by Find(), and Union().


|
inline |
Returns the rank of element Key.
Definition at line 221 of file gbase.h.
References THash< TKey, TDat, THashFunc >::GetDat(), KIdSetH, and TPair< TVal1, TVal2 >::Val2.
Referenced by Union().


| void TUnionFind::Union | ( | const int & | Key1, |
| const int & | Key2 | ||
| ) |
Merges sets with elements Key1 and Key2.
Definition at line 40 of file gbase.cpp.
References Find(), Parent(), and Rank().
Referenced by TSnap::TSnapDetail::TCNMQMatrix::MergeBestQ().

