In sage 2.10, if you type
sage: graphs?

The whole bottom part of the documentation clearly explains how to use
the graph iterator. You don't need to dig around in any source for
that.
I'll add a line at the top that indicates to go down for that...

> Okay, then I have a different question.  Is it possible or even
> somewhat efficient to first generate all graphs of n vertices (for n
> small, whatever that means) and then test them for a property such as
> size == m?  E.g. something like
> sage: L=list(graphs(3))
> sage: M=filter(lambda G: G.size()==3, L)
> sage: M
> [Graph on 3 vertices]

The graphs(...) construction is naturally an iterator, so instead of
constructing a list, just iterate through them, saving the ones you
need. Try this:
sage: def check_size(g):
....:     return g.size() == 6
....:
sage: L = []
sage: for g in graphs(7):
....:     if check_size(g):
....:         L.append(g)
....:

> Even the syntax of the graphs_list.show_graphs(list) is pretty thorny
> and certainly nonintuitive compared to the rest of Sage graphics,

Can you give an example of what you're talking about? Given any
arbitrary
list of Sage objects, the only obvious choice I can think of is the
GraphicsArray object, which usually wants a list of lists anyway. The
whole
reason we wrote the graphs_list set of functions was to make it easier
to
get nice plots of lists of graphs. It would be much easier for us to
make
you happy regarding this point if you could give us an example of
other
sage objects that act so nicely.

> Having to use lambda constructions (which are very hard to understand
> coming from the math side of things) to do what I am trying to do is too
> much.

There is no need to use lambda constructions at all- they are just
functions!
For example, try the following:

sage: def is_bip(g):
....:     return g.is_bipartite()
....:
sage: for g in graphs(5, is_bip):
....:     print g.graph6_string()
....:
D??
D_?
Do?
Ds?
Ds_
D`?
Dp?
Dr?
D`_
Dp_
Dh_
Dl_
Dlg

Finally, regarding efficiency, there are absolutely no guarantees. The
canonical labeling of graphs is somewhat competitive, but it still has
a ways to go to catch up, and it is currently going through a major
overhaul by yours truly. As far as generating graphs goes, you should
not expect it to be fast at all. All that is implemented right now is
in Python, all the property checks are in Python, and no optimizations
of any kind have been done. What needs to happen first is optimization
of the canonical labeling function.
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to