On 10/13/11 3:05 AM, P Purkayastha wrote:
It seems to be a more general bug in the function *graphs()*. Even this
code fails to give any output:
def isc(g): return g.is_clique()
Genn = graphs(3, isc)
[_ for _ in Genn]
Read the documentation a little closer (or maybe the documentation needs
to be expanded...). The property function happens *before* all graphs
are generated, works in conjunction with the 'augment' parameter (which
defaults to 'edges'). The docs for 'augment=edges' says:
* ``'edges'`` -- augments a fixed number of vertices by adding
one edge. In this case, all graphs on exactly ``n=vertices``
are generated. If for any graph G satisfying the property,
every subgraph, obtained from G by deleting one edge but not
the vertices incident to that edge, satisfies the property,
then this will generate all graphs with that property. If this
does not hold, then all the graphs generated will satisfy the
property, but there will be some missing.
For your example above, it's sufficient to change to augment=vertices,
since your property is preserved by deleting vertices:
sage: list(graphs(3, lambda x: x.is_clique(), augment='vertices'))
[Graph on 0 vertices, Graph on 1 vertex, Graph on 2 vertices, Graph on 3
vertices]
Notice your property does not hold when deleting edges, so there is no
guarantee graphs() will return all such graphs.
In Dima's example, the property is not inherited when deleting vertices
or edges (always, anyway), so there isn't any guarantee either way.
Dima should just filter the list of graphs after generating them all.
The purpose for the property function is to cut down on the time to
generate a list of graphs in special cases (inherited properties), not
to act as a substitute for filtering the entire list of graphs after
generation.
Thanks,
Jason
P.S. I notice that trying Dima's example isn't too successful. It's
because is_regular raises an error for 0-vertex graphs. I think we
should change is_regular to special-case 0-vertex graphs (and I think
they should be considered regular, but maybe people more into graph
theory have a different opinion).
--
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