data_structures.disjoint_set.alternate_disjoint_set =================================================== .. py:module:: data_structures.disjoint_set.alternate_disjoint_set .. autoapi-nested-parse:: Implements a disjoint set using Lists and some added heuristics for efficiency Union by Rank Heuristic and Path Compression Classes ------- .. autoapisummary:: data_structures.disjoint_set.alternate_disjoint_set.DisjointSet Module Contents --------------- .. py:class:: DisjointSet(set_counts: list) .. py:method:: get_parent(disj_set: int) -> int Find the Parent of a given set >>> A = DisjointSet([1, 1, 1]) >>> A.merge(1, 2) True >>> A.get_parent(0) 0 >>> A.get_parent(1) 2 .. py:method:: merge(src: int, dst: int) -> bool Merge two sets together using Union by rank heuristic Return True if successful Merge two disjoint sets >>> A = DisjointSet([1, 1, 1]) >>> A.merge(1, 2) True >>> A.merge(0, 2) True >>> A.merge(0, 1) False .. py:attribute:: max_set .. py:attribute:: parents .. py:attribute:: ranks .. py:attribute:: set_counts