On Sun, Jul 25, 2010 at 2:01 PM, Nathann Cohen <nathann.co...@gmail.com> wrote: > Nonononoooo, I understood why there are two copies of what appears to > be a "zero", and I think it's fine like that !
This is definitely *not* fine, since we have sage: int(0) == Mod(0, 20) True As input, the underlying C graph ends up corrupted (see below for details). Since they are equal, Sage's graphs should treat them as equal and they do not. Bug. To belabor the point for clarity: When you call g.vertices(), it calls iterator_verts in c_graph.pyx: {{{ cdef int i cdef object v if verts is None: S = set(self.vertex_ints.iterkeys()) for i from 0 <= i < (<CGraph>self._cg).active_vertices.size: if (i not in self.vertex_labels and bitset_in((<CGraph>self._cg).active_vertices, i)): S.add(i) return iter(S) }}} At this point we have: {{{ active_vertices == 1111111111111111111110000000000000000000 vertex_ints == {0: 20, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15, 16: 16, 17: 17, 18: 18, 19: 19} vertex_labels == {1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15, 16: 16, 17: 17, 18: 18, 19: 19, 20: 0} }}} Note that there are 21 bits in active_vertices, so C int 0 and C int 20 are both vertices according to that. That first zero in vertex_ints is an IntegerMod, and the 20 it points to is a C int. Vice versa for the 20: 0 entry in vertex_labels. At first, the line {{{ S = set(self.vertex_ints.iterkeys()) }}} creates a set of size twenty, containing twenty IntegerMod's, the set {0, ..., 19}. When i == 0 in the loop {{{ for i from 0 <= i < (<CGraph>self._cg).active_vertices.size }}}, the inner branch discovers that 0 should be added to S, but since S is a set, and Mod(0, 20) is already in there, adding int(0) to it does nothing. So as I said before, the problem is created by line 1084 (in sage-4.5/4.5.1) of c_graph.pyx, namely: {{{ if (not isinstance(u, (int, long, Integer)) or }}} In fact this should check for any Sage object X for which {{{ Integer(Y) == X }}} is true for any Y. I hope this better illustrates the problem, and I hope I've convinced you that int(0) and Mod(0, 20) should *not* be considered distinct by Sage graphs. > > Sorry for this misunderstanding :-) > > Nathann > A: "Stop apologizing!" B: "I'm sorry!" -- Robert L. Miller http://www.rlmiller.org/ -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org