Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

laying out a large graph with graphviz

My daughters have made a game not unlike tic-tac-toe. Of course as I played it with them I started brute-forcing it in my head...

So at lunchtime I made a quick little Python script to 'solve' the game. And I wanted to see the results graphically, so I generated a dot file of all legal moves:

I've pasted the data here.

When I try and render it using dot, it takes forever and I abort it after a few hours.

If I render it using neato or sfdp etc, it takes a few seconds or less but the layout is impossible to actually read:

sfdp -x -Tpng data.dot > data.png 

sfdp

neato -x -Tpng data.dot > data.png 

neato

I would be happy for the resulting image to be several megapixels.

How can I lay out and render such a big graph? I am open to non-dot suggestions, like Python libraries that can do the layout too.

(somewhat related link)

Added: my Python script to solve the game and generate the dot file

like image 351
Will Avatar asked Nov 16 '12 13:11

Will


People also ask

How do you make a graph on Graphviz?

Create a graph object, assemble the graph by adding nodes and edges, and retrieve its DOT source code string. Save the source code to a file and render it with the Graphviz installation of your system. Use the view option/method to directly inspect the resulting (PDF, PNG, SVG, etc.) file with its default application.

What is Graphviz Neato?

neato is a reasonable default tool to use for undirected graphs that aren't too large (about 100 nodes), when you don't know anything else about the graph. neato attempts to minimize a global energy function, which is equivalent to statistical multi-dimensional scaling.

What language does Graphviz use?

Graphviz consists of a graph description language named the DOT language and a set of tools that can generate and/or process DOT files: dot. a command-line tool to produce layered drawings of directed graphs in a variety of output formats, such as (PostScript, PDF, SVG, annotated text and so on). neato.


1 Answers

Try this:

sfdp -x -Goverlap=scale -Tpng data.dot > data.png 

The -Goverlap preserves the layout but uniformly scales things up until there are no more node overlaps. I was able to get a ~77MB PNG that looks like this when you zoom out. enter image description here

like image 53
job Avatar answered Sep 20 '22 15:09

job