Plotting graph in sage

380 Views Asked by At

Is there a way to plot a (graph theory) graph in sage in such a way that physical distance between vertices is at least a threshold (say 1cm)?

Graph layouts should be the way to do it. I am looking for a solution which is not very complicated.

Context: I need to plot a cubic planar graph. The planar layout provided by sage is not very satisfactory (spring layout gives better planar drawings)

Thank you

1

There are 1 best solutions below

1
On

One of the options for plotting graphs is the circular layout, which is a way to space out vertices consistently.

sage: G = graphs.CubeGraph(4)
sage: G
4-Cube: Graph on 16 vertices
sage: G.plot(layout='circular')
Launched png viewer for Graphics object consisting of 49 graphics primitives

Other options are documented in the documentation which can be accessed by:

sage: G.plot?

One can also show the graph using javascript:

sage: G.show(method='js')

Note that one can also set the positions of the vertices explicitly, see the set_pos method of graphs.

For more on set_pos and all graph plotting topics: