Public Member Functions | Private Attributes

ColPack::DisjointSets Class Reference
[Auxiliary Classes]

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

ColPack::DisjointSets::DisjointSets (  ) 

Definition at line 31 of file DisjointSets.cpp.

ColPack::DisjointSets::DisjointSets ( int  li_SetSize  ) 

Definition at line 38 of file DisjointSets.cpp.

References _UNKNOWN, and p_vi_Nodes.

ColPack::DisjointSets::~DisjointSets (  ) 

Definition at line 46 of file DisjointSets.cpp.

References p_vi_Nodes.


Member Function Documentation

int ColPack::DisjointSets::Count (  ) 

Count the number of sets contained by this DisjointSets object.

Definition at line 63 of file DisjointSets.cpp.

References _FALSE, and p_vi_Nodes.

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 115 of file DisjointSets.cpp.

References _FALSE, and p_vi_Nodes.

int ColPack::DisjointSets::FindAndCompress ( int  li_Node  ) 

Find the Set ID of this element, also shorten the tree by updating all elements with its new SetID.

Definition at line 130 of file DisjointSets.cpp.

References _FALSE, and p_vi_Nodes.

Referenced by ColPack::GraphColoring::AcyclicColoring(), ColPack::GraphColoring::AcyclicColoring_ForIndirectRecovery(), ColPack::HessianRecovery::IndirectRecover_CoordinateFormat(), ColPack::HessianRecovery::IndirectRecover_RowCompressedFormat(), and ColPack::HessianRecovery::IndirectRecover_SparseSolversFormat().

Here is the caller graph for this function:

int ColPack::DisjointSets::Print (  ) 

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

Definition at line 86 of file DisjointSets.cpp.

References _TRUE, p_vi_Nodes, 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 53 of file DisjointSets.cpp.

References _TRUE, _UNKNOWN, and p_vi_Nodes.

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 157 of file DisjointSets.cpp.

References _TRUE, and p_vi_Nodes.

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 172 of file DisjointSets.cpp.

References _TRUE, and p_vi_Nodes.

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 202 of file DisjointSets.cpp.

References _TRUE, and p_vi_Nodes.

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]