#15278: Hash and equality for graphs
-------------------------------------+-------------------------------------
       Reporter:  SimonKing          |        Owner:
           Type:  defect             |       Status:  needs_info
       Priority:  major              |    Milestone:  sage-6.1
      Component:  graph theory       |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Simon King         |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/SimonKing/ticket/15278           |  2fc8a772ee12fce7ac6abc4ecf9916f4746f5ee2
   Dependencies:  #12601, #15491     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by SimonKing):

 Replying to [comment:51 ncohen]:
 > > I've never heard before that Python uses it.
 >
 > Oh. Then I guess we are the only ones to use this `._immutable` flag.

 Ahem. Then I guess there are many things in Python that I've never heard
 of...

 > > But one question on copying needs to be addressed: I think in some
 places in Sage, `copy(X)` returns `X` if `X` is immutable, but in other
 places in Sage, `copy(X)` always returns a ''mutable'' copy of `X`,
 regardless whether `X` is mutable or not. What would you prefer for
 graphs?
 > >
 >
 > Hmmm... Well, I guess it makes more sense to get with "copy" the same
 kind of object that was given as input.

 From my perspective, this behaviour would be fine. But I also see this:
 {{{
 sage: M = matrix([[1,2,3],[4,5,6]])
 sage: M.set_immutable()
 sage: M.is_immutable()
 True
 sage: m = copy(M)
 sage: m.is_immutable()
 False
 }}}
 There is one crucial difference, though: A mutable matrix can be made
 immutable, by `M.set_immutable()`. But a mutable graph can (currently?)
 not easily be made immutable, since mutability crucially relies on the
 backend, which is not the case for matrices.

 Anyway, I don't think that there is a commonly accepted standard in Sage.
 Since we have no `G.set_immutable()` method for graphs, I guess it is
 better to have
 - `copy(G)` has the same backend as G. In particular, mutability is
 copied. And if it is immutable, then we should have `G is copy(G)`.
 - If one wants an immutable/mutable copy of a mutable/immutable graph G,
 then it should be done either by `Graph(G,backend='...')` or
 `G.copy(backend='...')` respectively with a to-be-implemented
 `mutable=True/False` keyword.

--
Ticket URL: <http://trac.sagemath.org/ticket/15278#comment:52>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to