-
-
Notifications
You must be signed in to change notification settings - Fork 674
Closed
Description
I would like to have an easy to use disjoint-set data structure like the one described here:
http://en.wikipedia.org/wiki/Disjoint_set_data_structure
sage: d = DisjointSet(range(5))
sage: d
{{0}, {1}, {2}, {3}, {4}}
sage: d.union(3,4)
sage: d
{{0}, {1}, {2}, {3, 4}}
sage: d.union(0,2)
sage: d
{{0, 2}, {1}, {3, 4}}
sage: d.union(1,4)
sage: d.find(3)
3
sage: d.find(4)
3
As suggested by Robert Miller on sage-devel, one could use what is defined in
sage/groups/perm_gps/partn_ref/data_structures_*
CC: @rlmill
Component: combinatorics
Keywords: disjoint set data structure
Author: Sébastien Labbé
Reviewer: Robert Miller
Merged: sage-4.3.3.alpha0
Issue created by migration from https://trac.sagemath.org/ticket/6775