Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize DisjointSet #37835

Merged
merged 6 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sage/groups/perm_gps/partn_ref/data_structures.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ cdef inline int OP_find(OrbitPartition *OP, int n) noexcept:
OP.parent[n] = OP_find(OP, OP.parent[n])
return OP.parent[n]

cdef inline int OP_join(OrbitPartition *OP, int m, int n) noexcept:
cdef inline void OP_join(OrbitPartition *OP, int m, int n) noexcept:
"""
Join the cells containing m and n, if they are different.
"""
Expand Down
16 changes: 14 additions & 2 deletions src/sage/sets/disjoint_set.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,25 @@
from sage.groups.perm_gps.partn_ref.data_structures cimport OrbitPartition
from sage.structure.sage_object cimport SageObject

cpdef DisjointSet(arg)

cdef class DisjointSet_class(SageObject):
cdef OrbitPartition *_nodes
cpdef cardinality(self)
cpdef number_of_subsets(self)

cdef class DisjointSet_of_integers(DisjointSet_class):
pass
cpdef int find(self, int i)
cpdef void union(self, int i, int j)
cpdef root_to_elements_dict(self)
cpdef element_to_root_dict(self)
cpdef to_digraph(self)

cdef class DisjointSet_of_hashables(DisjointSet_class):
cdef list _int_to_el
cdef dict _el_to_int
cdef DisjointSet_of_integers _d
cpdef find(self, e)
cpdef void union(self, e, f)
cpdef root_to_elements_dict(self)
cpdef element_to_root_dict(self)
cpdef to_digraph(self)
Loading
Loading