# Strategies for plotting graphs with many vertices

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 close merge delete

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

( 2020-08-21 16:45:47 +0200 )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.

( 2020-08-22 03:50:09 +0200 )edit

Sort by ยป oldest newest most voted

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.

more

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.

( 2020-08-22 03:47:38 +0200 )edit
1

The documentation is here. Try

Gex.show(method='js', vertex_colors=ecol, vertex_size=50, link_distance=500)

( 2020-08-22 11:55:49 +0200 )edit

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

( 2020-08-23 06:46:26 +0200 )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.

( 2020-12-15 22:50:06 +0200 )edit