Skip to main content

UFDS

Instantiate a UFDS with a number of disjoint sets

Usage

UFDS(sets:int)

Parameters:
      sets : int
            The number of disjoint sets to create

Methods

MethodDescription
find_setFinds the representative node of the set containing 'item_number'
is_same_setChecks if 2 items belong to the same set
unionUnions 2 sets together
moveMove an item from its original set to a new set
count_itemsCount the number of items in a particular set

Example

from jellybeans.structures import UFDSufds = UFDS(10) # 10 disjoint sets are created