Implementing Disjoint Set System In Python

后端 未结 5 462
无人及你
无人及你 2021-01-19 03:47

What I have so far is largely based off page 571 of \"Introduction To Algorithms\" by Cormen et al.

I have a Node class in python that represents a set:



        
5条回答
  •  孤独总比滥情好
    2021-01-19 04:08

    Presuming that each node is initialised to be its own parent:

    def Find(node):
        while node is not node.parent:
            node = node.parent
        return node
    

提交回复
热议问题