1 | initial version |
The output of a command like graphs.planar_graphs(4)
is an iterator
that can yield all planar graphs with the specified number of vertices.
To get the documentation, do one of the following:
in Sage, type graphs.planar_graph?
and hit the return or enter key.
This will display the documentation for this function, in text mode.
in Sage, type graphs.planar_graph??
and hit the return or enter key.
This will display the code source for this function, including the documentation string.
in Sage, type browse_sage_doc(graphs.planar_graph)
.
This will open the documentation for this function, in html, in a browser tab.
browse the online documentation:
So for example, if you define
sage: gen = graphs.planar_graphs(n)
and turn it into a list
sage: G = list(gen)
you could display a summary of this list of graphs and their diameters:
sage: newline = '\n'
sage: s = 'There are {} planar graphs on {} vertices.'
sage: s = s.format(n, len(G))
sage: for j, g in enumerate(G):
....: s += newline + '{}.'.format(j)
....: s += newline + 'Edges: {}'.format(g.edges(labels=False))
....: s += newline + 'Diameter: {}'.format(g.diameter())
....:
sage: print(s)
There are 4 planar graphs on 6 vertices.
0.
Edges: [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)]
Diameter: 1
1.
Edges: [(1, 2), (1, 3), (2, 3), (2, 4), (3, 4)]
Diameter: 2
2.
Edges: [(1, 2), (1, 3), (2, 4), (3, 4)]
Diameter: 2
3.
Edges: [(1, 2), (2, 3), (2, 4), (3, 4)]
Diameter: 2
4.
Edges: [(1, 2), (2, 3), (3, 4)]
Diameter: 3
5.
Edges: [(1, 2), (2, 3), (2, 4)]
Diameter: 2
or plot them all:
sage: for g in G:
....: plot(g)
....:
Launched png viewer for Graphics object consisting of 11 graphics primitives
Launched png viewer for Graphics object consisting of 10 graphics primitives
Launched png viewer for Graphics object consisting of 9 graphics primitives
Launched png viewer for Graphics object consisting of 9 graphics primitives
Launched png viewer for Graphics object consisting of 8 graphics primitives
Launched png viewer for Graphics object consisting of 8 graphics primitives
etc.
Don't hesitate to suggest any specific improvement to the documentation.