data_structures.disjoint_set.disjoint_set

Disjoint set. Reference: https://en.wikipedia.org/wiki/Disjoint-set_data_structure

Classes

Node

Functions

find_python_set(→ set)

Return a Python Standard Library set that contains i.

find_set(→ Node)

Return the parent of x

make_set(→ None)

Make x as a set.

test_disjoint_set(→ None)

union_set(→ None)

Union of two sets.

Module Contents

class data_structures.disjoint_set.disjoint_set.Node(data: int)
data
parent: Node
rank: int
data_structures.disjoint_set.disjoint_set.find_python_set(node: Node) set

Return a Python Standard Library set that contains i.

data_structures.disjoint_set.disjoint_set.find_set(x: Node) Node

Return the parent of x

data_structures.disjoint_set.disjoint_set.make_set(x: Node) None

Make x as a set.

data_structures.disjoint_set.disjoint_set.test_disjoint_set() None
>>> test_disjoint_set()
data_structures.disjoint_set.disjoint_set.union_set(x: Node, y: Node) None

Union of two sets. set with bigger rank should be parent, so that the disjoint set tree will be more flat.