Implementing Disjoint Set System In Python

后端 未结 5 482
无人及你
无人及你 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:28

    Using this implementation as a starting point, I've created a new python class to handle disjoint sets, which also supports persistence using a MongoDb.

    With my class you should be able, for example, to:

    • Create an instance of UnionFind(), which uses python build-in dictionaries by default, and decide later to consolidate() your results in a MongoDb collection
    • Create an instance of UnionFind from a MongoDb collection and directly use it.

    You might want to check the code on github.

    Cheers, Simone

提交回复
热议问题