Ask Your Question
1

Strategies for plotting graphs with many vertices

asked 2020-08-21 00:45:51 +0100

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 16:45:47 +0100 )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-22 03:50:09 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-08-21 16:48:52 +0100

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-22 03:47:38 +0100 )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 11:55:49 +0100 )edit

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

HallaSurvivor gravatar imageHallaSurvivor ( 2020-08-23 06:46:26 +0100 )edit

Wow, that was great. I was getting sick of cluttered graphs since I made a random graph generator and nodes past about 15 were almost unreadable. Sagemath documentation is sooo spread out. Or incredibly advanced for what I want to do. I was hoping to find a native method and didn't think of javascript.

cybervigilante gravatar imagecybervigilante ( 2020-12-15 22:50:06 +0100 )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-21 00:45:51 +0100

Seen: 684 times

Last updated: Aug 21 '20