0
$\begingroup$

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

$\endgroup$
2
  • 1
    $\begingroup$ Please provide code to produce the graph you are interested in plotting. This will make it easier for others to come up with relevant answers to your question. $\endgroup$ Jun 4, 2019 at 14:43
  • $\begingroup$ @SamuelLelièvre I would be interested in a general approach towards it. I think plotting a graph without vertices overlapping is a basic functionality. $\endgroup$ Jun 5, 2019 at 3:52

1 Answer 1

2
$\begingroup$

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:

$\endgroup$
1
  • 1
    $\begingroup$ Thank you very much for pointing out G.plot? $\endgroup$ Jun 5, 2019 at 6:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .