Re: [sage-devel] Re: DiGraph, int vs. sage Integer
On Mon, 10 Aug 2015, Vincent Delecroix wrote: But sage: G = Graph() sage: G.add_vertices(range(100)) sage: set(type(x) for x in G.vertices()) {} I guess you meant G.add_vertices(IntegerRange(100)). But still true, so it goes. And also G.add_vertices(IntegerRange(1,100)) gives 'Integer' and 'int'. And also G = Graph() G.add_vertices([0,1,2,3,4,5,6,7,8,9,10,11]) G.delete_vertex(4) set(type(x) for x in G.vertices()) is different from G = Graph() G.add_vertices([0,1,2,3,5,6,7,8,9,10,11]) set(type(x) for x in G.vertices()) and this seems quite unexpected. True. The number 10 is just the size of the initial allocated memory. OK. I don't like magic numbers... But anyway, maybe this should be leave as it is. Or maybe just documented, if it is not already. -- Jori Mäntysalo
Re: [sage-devel] Re: DiGraph, int vs. sage Integer
On 10/08/15 09:40, Jori Mäntysalo wrote: On Mon, 10 Aug 2015, Vincent Delecroix wrote: Sounds reasonable. However, it seems to optimize only numbers from 0 to 9. Here is a test code: No. You are wrong. You can just have a look to the code publicly available. It is the class CGraphBackend in the file src/sage/graphs/base/c_graph.pyx that manage the labels. ??? For example I got [, ] from g = Graph() g.add_vertex(9) g.add_vertex(10) [type(x) for x in g.vertices()] But sage: G = Graph() sage: G.add_vertices(range(100)) sage: set(type(x) for x in G.vertices()) {} > > and this seems quite unexpected. > True. The number 10 is just the size of the initial allocated memory. Vincent -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: DiGraph, int vs. sage Integer
On Mon, 10 Aug 2015, Vincent Delecroix wrote: Sounds reasonable. However, it seems to optimize only numbers from 0 to 9. Here is a test code: No. You are wrong. You can just have a look to the code publicly available. It is the class CGraphBackend in the file src/sage/graphs/base/c_graph.pyx that manage the labels. ??? For example I got [, ] from g = Graph() g.add_vertex(9) g.add_vertex(10) [type(x) for x in g.vertices()] and this seems quite unexpected. -- Jori Mäntysalo
Re: [sage-devel] Re: DiGraph, int vs. sage Integer
On 10/08/15 09:19, Jori Mäntysalo wrote: On Sun, 9 Aug 2015, Nathann Cohen wrote: Is this a bug? If not, what is the rationale behind this? What I know is that it was done deliberately, and I do not know the rationale. I can "guess" that it was because "you pay for labels", and that Robert Miller thought that there was no reason to pay for them when the vertices were labelled with integers. Sounds reasonable. However, it seems to optimize only numbers from 0 to 9. Here is a test code: No. You are wrong. You can just have a look to the code publicly available. It is the class CGraphBackend in the file src/sage/graphs/base/c_graph.pyx that manage the labels. I would say that this is a bug. To what way should this be unified, that I left others to decide. I agree that this is not very well documented and might be annoying. One way to fix it is to say *at creation* whether we want to use labels or not. Vincent -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: DiGraph, int vs. sage Integer
On Sun, 9 Aug 2015, Nathann Cohen wrote: Is this a bug? If not, what is the rationale behind this? What I know is that it was done deliberately, and I do not know the rationale. I can "guess" that it was because "you pay for labels", and that Robert Miller thought that there was no reason to pay for them when the vertices were labelled with integers. Sounds reasonable. However, it seems to optimize only numbers from 0 to 9. Here is a test code: g1 = DiGraph({11:[9]}) print [(x, type(x)) for x in g1.vertices()] g2 = DiGraph({8:[12]}) print [(x, type(x)) for x in g2.vertices()] I would say that this is a bug. To what way should this be unified, that I left others to decide. I have NOT made a trac ticket, and won't look after this for a long time, so hopefully somebody catches this. -- Jori Mäntysalo
[sage-devel] Re: DiGraph, int vs. sage Integer
> > Is this a bug? If not, what is the rationale behind this? > What I know is that it was done deliberately, and I do not know the rationale. I can "guess" that it was because "you pay for labels", and that Robert Miller thought that there was no reason to pay for them when the vertices were labelled with integers. Nathann -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.