Currently it impossible to use DisjointSet objects as keys due to the lack of hashability. For example, hash(DisjointSet(5)) gives an error TypeError: unhashable type: 'sage.sets.disjoint_set.DisjointSet_of_integers'
Proposed Solution
Add immutability option for DisjointSet objects (say, like the one in graphs).
Alternatives Considered
Alternatively, a reasonable option is to convert to a SetPartition object, which is hashable. However, the reverse conversion is currently broken - see #38415
Additional Information
No response
Is there an existing issue for this?
[X] I have searched the existing issues for a bug report that matches the one I want to file, without success.
Problem Description
Currently it impossible to use
DisjointSet
objects as keys due to the lack of hashability. For example,hash(DisjointSet(5))
gives an errorTypeError: unhashable type: 'sage.sets.disjoint_set.DisjointSet_of_integers'
Proposed Solution
Add immutability option for
DisjointSet
objects (say, like the one in graphs).Alternatives Considered
Alternatively, a reasonable option is to convert to a
SetPartition
object, which is hashable. However, the reverse conversion is currently broken - see #38415Additional Information
No response
Is there an existing issue for this?