Re: [sage-devel] Graph() construction with edge function

2015-10-16 Thread Rob Beezer
Nathann - Looks great - thanks! -Rob On Friday, October 16, 2015 at 3:38:41 AM UTC-7, Nathann Cohen wrote: > > Helloo, > > > Yes, I think if the documentation screams "implements a symmetric > relation" > > that would be a big improvement. And maybe a doctest illustrating how > it > > c

Re: [sage-devel] Graph() construction with edge function

2015-10-16 Thread Nathann Cohen
Helloo, > Yes, I think if the documentation screams "implements a symmetric relation" > that would be a big improvement. And maybe a doctest illustrating how it > can go bad? I added a mention that the function should be symmetric, and just pushed a new doctest for that: http://git.sag

Re: [sage-devel] Graph() construction with edge function

2015-10-15 Thread Rob Beezer
Dear Nathann, Yes, I think if the documentation screams "implements a symmetric relation" that would be a big improvement. And maybe a doctest illustrating how it can go bad? Thanks very much for looking after this one. I am a little familiar with that constructor, I'm sure you will have fuu

Re: [sage-devel] Graph() construction with edge function

2015-10-15 Thread Nathann Cohen
> But we should have a documented unified policy to this. As an example, if > Graph(.., f) assumes f to be symmetric without checking, then Poset(..., f) > should assume that f does not define a loop on elements and so on. Right now the Poset function does not delegate the job of building the digr

Re: [sage-devel] Graph() construction with edge function

2015-10-15 Thread Jori Mäntysalo
Quoting Nathann Cohen : So should the "edge-detection" function be required to return true for any pair of vertices joined by an edge, or should there be an edge constructed between any pair of vertices for which the edge-detection function returns true? The best for me is to request that the

Re: [sage-devel] Graph() construction with edge function

2015-10-14 Thread Nathann Cohen
Hello, Sorry for the change in behaviour, perhaps I should write somewhere that 'f' must be symmetric. I could do so in #19390, for it actually cleans the constructor code and their documentation. So should the "edge-detection" function be required to return true for any > pair of vertices joi

Re: [sage-devel] Graph() construction with edge function

2015-10-14 Thread Rob Beezer
Well, the first thing I tried was (i-j)^2 == 1. ;-) Partially answering my own question, by reading the code (graphs/graph.py): from itertools import combinations self.add_vertices(verts) self.add_edges(e for e in combinations(verts,2) if f(*e)) self.add_edges((v,v) for v in verts if f(v,v))

Re: [sage-devel] Graph() construction with edge function

2015-10-14 Thread Vincent Delecroix
I would rather use P9 = Graph([[0..8], lambda i,j: abs(i-j) == 1]) since edges have no reason to be ordered with i>j or i The following used to work (based on regular private doctesting outside of Sage source code) and give you the path you wanted: P9 = Graph([[0..8], lambda i,j: i-j == 1])

[sage-devel] Graph() construction with edge function

2015-10-14 Thread Rob Beezer
The following used to work (based on regular private doctesting outside of Sage source code) and give you the path you wanted: P9 = Graph([[0..8], lambda i,j: i-j == 1]) Now it silently produces an empty graph (9 vertices, no edges). The fix: P9 = Graph([[0..8], lambda i,j: i-j == -1]) Is thi

[sage-devel] graph construction

2009-05-10 Thread Rado
I was playing with some big(10^6) graphs and noticed SAGE cannot handle constructing them in good time. However, networkx does just fine. Before I dive into the code, is this a feature (i.e. sage graph object has richer data and methods available) or this is a bug? sage: D={} sage: for i in xrang