Nathann, Using the following instead fixes the problem:
g.add_edges( (Mod(i,n),Mod(i+j,n)) for i in range(n) for j in range(1,k+1) ) This is more consistent, since we are actually using the same vertex objects. However, that should just work, right? Why doesn't it? This is coming from the code around line 1000 of c_graph, which goes from vertex labels to ints and back. The IntegerMod case was not in mind when this code was written. The real problem is that when the Python int 0 gets passed to get_vertex, it does not add the entry to the translation dictionary. The idea being that it would be more efficient for the majority of graphs, which only use [0, 1, ..., n-1] as labels, going through dictionaries a bunch would be a waste. However, when the IntegerMod 0 gets passed in, it does not find an equal object in the dict, and since it is not one of {int, long, Integer}, it assigns a new int in the translation dictionary for it. So that's what's happening, what do people think about what we should do about this? Technically the input is a bit fuzzy, but this raises the question of how many other objects are there which will pass the test int(0) == IntegerMod(0, 20)... I am very reluctant to support adding all the labels to the dicts, unless someone can show that there really isn't any overhead there... -- 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