First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Iterators are wonderful.

One of the ways in which they are wonderful is you can grab as many or as few elements as you want.

The iterator for all planar graphs of order 50:

sage: planar_50 = graphs.planar_graphs(50)

Grab the first four:

sage: planar_50_4 = [next(planar_50) for _ in range(4)]

Check:

sage: planar_50_4
[Graph on 50 vertices,
 Graph on 50 vertices,
 Graph on 50 vertices,
 Graph on 50 vertices]