ColPack
ColPack::DisjointSets Class Reference

class DisjointSets in group4. More...

#include <DisjointSets.h>

List of all members.

Public Member Functions

 DisjointSets ()
 DisjointSets (int)
 ~DisjointSets ()
int SetSize (int)
 Set the size of this DisjointSets object, i.e. resize the vector p_vi_Nodes.
int Count ()
 Count the number of sets contained by this DisjointSets object.
int Print ()
 Print out the elements' ID and their values (i.e., p_vi_Nodes's IDs and values)
int Find (int)
 Find the Set ID of this element.
int FindAndCompress (int)
 Find the Set ID of this element, also shorten the tree by updating all elements with its new SetID.
int Union (int li_SetOne, int li_SetTwo)
 Union li_SetOne with li_SetTwo by seting li_SetOne to be the parent of li_SetTwo.
int UnionByRank (int li_SetOne, int li_SetTwo)
 Union li_SetOne with li_SetTwo by their ranks.
int UnionBySize (int li_SetOne, int li_SetTwo)
 Union li_SetOne with li_SetTwo by their sizes.

Private Attributes

vector< int > p_vi_Nodes

Detailed Description

class DisjointSets in group4.

The disjoint set class is used by ColPack to store and operate on disjoint sets of edges identified by integer numbers. A disjoint set class can be instantiated by specifying the maximum number of such sets to be stored. The elements in a set are stored as a tree and the identifier of the set (SetID) is the identifier of the root. The size of the tree is stored in the root and the parent of an element is stored in the element. The tree is implemented simply as a vector of integers the indices being the identifiers of the elements.

Definition at line 37 of file DisjointSets.h.


Constructor & Destructor Documentation

Definition at line 33 of file DisjointSets.cpp.

Definition at line 40 of file DisjointSets.cpp.

References _UNKNOWN.

Definition at line 48 of file DisjointSets.cpp.


Member Function Documentation

Count the number of sets contained by this DisjointSets object.

Definition at line 65 of file DisjointSets.cpp.

References _FALSE.

Referenced by ColPack::GraphColoring::AcyclicColoring().

Here is the caller graph for this function:

int ColPack::DisjointSets::Find ( int  li_Node)

Find the Set ID of this element.

Definition at line 117 of file DisjointSets.cpp.

References _FALSE.

Print out the elements' ID and their values (i.e., p_vi_Nodes's IDs and values)

Definition at line 88 of file DisjointSets.cpp.

References _TRUE, and STEP_DOWN.

int ColPack::DisjointSets::SetSize ( int  li_SetSize)

Set the size of this DisjointSets object, i.e. resize the vector p_vi_Nodes.

Definition at line 55 of file DisjointSets.cpp.

References _TRUE, and _UNKNOWN.

Referenced by ColPack::GraphColoring::AcyclicColoring(), and ColPack::GraphColoring::AcyclicColoring_ForIndirectRecovery().

Here is the caller graph for this function:

int ColPack::DisjointSets::Union ( int  li_SetOne,
int  li_SetTwo 
)

Union li_SetOne with li_SetTwo by seting li_SetOne to be the parent of li_SetTwo.

Return the SetID of the new set. In this case, SetID will be li_SetOne

Definition at line 159 of file DisjointSets.cpp.

References _TRUE.

int ColPack::DisjointSets::UnionByRank ( int  li_SetOne,
int  li_SetTwo 
)

Union li_SetOne with li_SetTwo by their ranks.

Rank: the upper bound on the height of the tree (or set) The root of each set will hold its the negate of its set rank i.e. rank of set 2 is (-p_vi_Nodes[2])

Note: UnionByRank() and UnionBySize() can not be used together to solve the same problem due to the different meaning of the root's value

Definition at line 174 of file DisjointSets.cpp.

References _TRUE.

int ColPack::DisjointSets::UnionBySize ( int  li_SetOne,
int  li_SetTwo 
)

Union li_SetOne with li_SetTwo by their sizes.

The root of each set will hold its the negate of its set size i.e. size of set 2 is (-p_vi_Nodes[2])

Note: UnionByRank() and UnionBySize() can not be used together to solve the same problem due to the different meaning of the root's value

Definition at line 204 of file DisjointSets.cpp.

References _TRUE.

Referenced by ColPack::GraphColoring::AcyclicColoring(), and ColPack::GraphColoring::AcyclicColoring_ForIndirectRecovery().

Here is the caller graph for this function:


Member Data Documentation

vector<int> ColPack::DisjointSets::p_vi_Nodes [private]

Definition at line 41 of file DisjointSets.h.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines