Ask Your Question
1

Drawing a planar multigraph with loops

asked 2018-01-10 14:00:59 +0100

A.P. gravatar image

I would like to draw a planar graph with multiple edges and loops in Sage. Unfortunately, the default algorithm draws may intersecting edges and Sage is unable to compute an embedding for graphs with loops multiple edges.

Fortunately I know a planar embedding of this graph, so I tried using the set_embedding method, but it doesn't seem to work, either. If I only list a vertice's the neighbours, omitting their multiplicities, Sage complains that the list is shorter than the vertice's degree, while if I include multiple copies of each neighbour according to multiplicity, then Sage complains that elements of the list aren't unique.

Is there a way to achieve what I need?

edit retag flag offensive close merge delete

Comments

2

Please provide code to generate the graph you are interested in.

This will make it a lot easier for other users to try to answer your question.

You can also say what you have tried and show how it fails and say what you would expect instead.

slelievre gravatar imageslelievre ( 2018-01-11 07:58:28 +0100 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2018-01-16 21:21:29 +0100

Sébastien gravatar image

Install graphviz on your system and install dot2tex:

sage -i dot2tex

Use it to generate tikz code:

sage: G =  ... your graph ....
sage: kwds = dict(format='dot2tex', edge_labels=True, color_by_label=False, prog='dot')
sage: G.latex_options().set_options(**kwds)
sage: tikz = graph._latex_()

View it:

sage: view(G)

You may test prog='neato' for another type of node placement.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-01-10 14:00:59 +0100

Seen: 818 times

Last updated: Jan 16 '18