Ask Your Question

Revision history [back]

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]