#17086: GenericGraph's documentation, __eq__, and __hash__ out of sync
-------------------------------------+-------------------------------------
       Reporter:  emassop            |        Owner:
           Type:  defect             |       Status:  new
       Priority:  major              |    Milestone:  sage-6.4
      Component:  graph theory       |   Resolution:
       Keywords:                     |    Merged in:
        Authors:                     |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/emassop/graph_hash               |  82b245ee0b092a7a994074e27cc47686d43551c9
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by ncohen):

 Hello !

 Thank you for this 'Counter' thing, I did not know that it existed `^^;`

 1) About `self.edge_iterator(labels = self._weighted)`:

 You can have graphs with edge labels for which _weighted is not True

 {{{
 sage: Graph([(1,2,"Hey")])._weighted
 False
 sage: Graph([(1,2,"Hey")],immutable=True)._weighted
 False
 }}}

 I do not think that this 'weighted' notion makes a lot of sense anyway,
 perhaps we should remove it. Either way it is probably best to set
 'labels' to `True` anytime.

 2) Perhaps I do not understand what your tests do, but even when the graph
 is immutable the list of vertices returned by `.vertices()` should be
 sorted. Do you have a counterexample to that ?

   Indeed, we cannot assume that sorting a list produces a unique sorted
 list (because the order is not always a total order) but that list,
 however, should be sorted.

   This, because even when the immutable graph is created, the vertices are
 labelled using the order returned by `.vertices()`. So I hope that you
 found no bad behaviour there.

   But indeed, wrapping it with a frozenset if the right thing to do.

 3) Technically, you do not need to add `._is_weighted` in the hash
 function, as graphs with different values for `._is_weighted` are nonequal
 anyway. But that does not hurt either.

 4) `O_O`

 {{{
 sage: G1 = Graph({0: {1: 'edge label A'}})
 sage: G2 = Graph({0: {1: 'edge label B'}})
 sage: G1 == G2
 True
 }}}

 This is *REALLY* bad ! Graphs with different labels should be non-equal
 !!! `O_O;;;;;`

 But it seems that it has been like that forever... Gosh that's bad `O_o`

 Hmmmm.. Now I understand why you added this `self._weighted` in the hash
 function `:-/`

 Nathann

--
Ticket URL: <http://trac.sagemath.org/ticket/17086#comment:3>
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/d/optout.

Reply via email to