Ask Your Question
1

Strategies for plotting graphs with many vertices

asked 2020-08-20 17:45:51 -0500

HallaSurvivor gravatar image

I've found that sage is good at drawing small graphs, but becomes decreasingly useful for visualizing your graph as the number of vertices increases. This is doubly true if you want to label your vertices. Oftentimes I feel like this is due to sage trying to keep the graph image somewhat small, and I would be happy to trade an image with large xy dimensions in exchange for more spread out vertices, which will give the labels room to be legible.

I know that sage will let you manually choose where the vertices go, but often I am drawing graphs to try to visualize things quickly to develop conjectures, and it is more important that I be able to go through lots of examples than it is to have each one perfect.

Does anyone know of a way to get sage to spread the vertices out more aggressively, and generally to get it to plot graphs with ~50 nodes while maintaining legibility? I'm aware there was a question about a similar topic here (apparently I don't have enough karma to post links: /question/9305/strategies-for-drawing-good-graphs-graph-theory/), but seeing as that was 8 years ago, it seems reasonable that there may have been some developments.

Thanks in advance ^_^

edit retag flag offensive close merge delete

Comments

Could you please provide a concrete example of a graph you want to plot (with labels, etc) ?

tmonteil gravatar imagetmonteil ( 2020-08-21 09:45:47 -0500 )edit

Here is a pastebin of my exact example right now. you'll see that the graph is illegible (it takes a while to compute, jsyk). For ease of reference, here is a screenshot.

HallaSurvivor gravatar imageHallaSurvivor ( 2020-08-21 20:50:09 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2020-08-21 09:48:52 -0500

Have you tried that:

sage: G = graphs.RandomBlockGraph(20, 4, kmax=6)                                                                                    
sage: G.show(method='js')

The graph is displayed using d3.js in your navigator, and it is now possible to export in SVG.

edit flag offensive delete link more

Comments

This looks like it could be really useful, but by default it still doesn't look very good. At the risk of seeming naive, are there settings I should be changing that I'm not? Here is how it ends up looking. This was generated with basically the same sage code is an my comment to tmonteil.

HallaSurvivor gravatar imageHallaSurvivor ( 2020-08-21 20:47:38 -0500 )edit
1

The documentation is here. Try

Gex.show(method='js', vertex_colors=ecol, vertex_size=50, link_distance=500)
David Coudert gravatar imageDavid Coudert ( 2020-08-22 04:55:49 -0500 )edit

Fantastic! Thanks for the docs ^_^ This is exactly what I wanted

HallaSurvivor gravatar imageHallaSurvivor ( 2020-08-22 23:46:26 -0500 )edit

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: 2020-08-20 17:45:51 -0500

Seen: 33 times

Last updated: Aug 20