#10886: DisjointSet: number of sets function
---------------------------------------+------------------------------------
Reporter: rlm | Owner: jason
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-4.7
Component: misc | Keywords:
Author: Robert Miller | Upstream: N/A
Reviewer: Alexandre Blondin Massé | Merged:
Work_issues: |
---------------------------------------+------------------------------------
Comment(by slabbe):
> 3. My question is mainly addressed to Sébastien but maybe you know
the answer. What is the reason for creating the class `DisjointSet_class`?
It says that it is supposed to contain functions common to all disjoint
set data structures, but it only contains two basic functions. Shouln't
functions such as `cardinality`, `number_of_sets`, etc. be there too?
I feel I would code that differently today... but let's try to remember
why I did it that way. The actual classes hierarchy is:
{{{
cdef class DisjointSet_class(SageObject):
cdef class DisjointSet_of_integers(DisjointSet_class):
cdef class DisjointSet_of_hashables(DisjointSet_class):
}}}
Right now, the important attributes are not in `DisjointSet_class` but in
the two others. Moreover, the attributes are not the same, so that almost
no method are coded the same way as you noticed.
I remember I hesitated to take the following hierarchy instead (in this
situation, an instance of `DisjointSet_of_hashables` would not contain an
attribute `DisjointSet_of_integers` as it is the case now) :
{{{
cdef class DisjointSet_of_integers(SageObject):
cdef class DisjointSet_of_hashables(DisjointSet_of_integers):
}}}
But, then almost every methods of `DisjointSet_of_integers` was
overwritten by `DisjointSet_of_hashables`. And since
`DisjointSet_of_hashables` is not a `DisjointSet_of_integers`, I was
feeling it was not a good hierarchy to choose. Maybe I did a mistake?
Indeed, in this situation, the method `number_of_sets` would be coded at
only one place.
What do you think?
Sébastien
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10886#comment:7>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.