#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:39 ncohen]:
 > HMmmmm... Don't you touch cachefunc.pyx in commit
 126b03609e9bae78955ccbc97e36f1924a79603b ? That's when you merge #12601 in
 the present branch.

 Splitting hair...

 > Gosh, I'm going to hate these git dependencies.

 +1

 > - In `.copy()`, you add a line before everything else to handle your
 case. Couldn't you add a line after the second "if" block, the one after
 which we know for sure that `data_structure` has been defined, saying "if
 data_structure == "static_sparse" and hasattr(self,'_immutable')" then
 return self ?

 I am working on it.

 > By the way, is an object considered mutable if it HAS a ._immutable
 variable equal to False ?

 Hmm. Would this be possible? I think a graph should be considered
 immutable if and only if the static backend is used---or rather if and
 only if ''some'' static backend is used: Perhaps there will be more static
 backends in future.

 So, instead of relying on an attribute `._immutable` that the user could
 mess with, one could test for the type of the backend when we need to know
 whether a graph is immutable.

 Problem: If I am not mistaken, people currently ''do'' mess with the
 attribute `._immutable`, if I am not mistaken.

 Would it be feasible to try to remove the `._immutable` attribute (and
 testing the type of the backend instead), see how much fails, and fix the
 failing code by using "proper" immutable graphs?

 > - Why wouldn't we add (later) a "immutable" flag to the constructor and
 to "copy" ?

 Would a flag in the "copy" function be supported by Python?

 > It would be nice to call `Graph(graphs.PetersenGraph(),immutable=True)`
 ? `O_o`

 Yes. Only problem: We would then need to decide what to do if
 "immutable=False" and "backend="static_sparse" is simultaneously used.

 > - What about an exception message for `_hash_` that would give the hint
 that hashable graphs can be built ? Something like "This graph is mutable,
 and thus not hashable. To make it mutable, read the doc of Graph.copy."

 OK.

--
Ticket URL: <http://trac.sagemath.org/ticket/15278#comment:46>
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