1

I have a large graph with many nodes and edges. The problem I am facing with the Graphviz python package is that rendering the file takes a lot of time.

There are other alternatives mentioned here and here. But the problem I am facing is that all of them work with the dot file, and these methods generate image files that do not look good; I mean, the formatting intended is not quite visible.

I want a pdf file to be generated. The large image files being generated are crashing my Linux. The default image viewer in Linux cannot handle them, or Mozilla Firefox, though it can open it, takes a tremendous amount of time for a portion of the image to become apparent.

Please can anyone help me generate a pdf file very fast which can be quickly viewed in usual pdf viewers or if an image, so can be easily viewed using usual image viewers?

I want the graphs generated to look something like this, this, and this. [These are the graphs rendered to pdf by python for a subgraph of the input].

For the entire graph, the situation of the dot file is like this, and the command:

$sfdp -x -Goverlap=scale -Tpng syscall > data.png
sfdp: graph is too large for cairo-renderer bitmaps. Scaling by 0.487931 to fit
tcmalloc: large alloc 3142361088 bytes == 0x558a701ce000 @  0x7f45c7679001 0x7f45c39101fa 0x7f45c39102ad 0x7f45c4a9b6df 0x7f45c4f92261 0x7f45c740f468 0x7f45c7411d53 0x558a6ee01092 0x7f45c6dc4c87 0x558a6ee0112a

It is returning the following data.png file, which I cannot view correctly on any image viewer on my Linux system. And also, it is not of the same format (the look of the graph, I mean) as generated by Graphviz render.

And for this dot file, even sfdp is taking considerable time...

Abhishek Ghosh
  • 597
  • 7
  • 18
  • 2
    Not enough information to really help Please include (or point to) your input. You also to better describe what you don't like about the resulting graph. – sroush Sep 24 '22 at 03:00
  • @sroush I have added the related pointers. Please can you help now. – Abhishek Ghosh Sep 24 '22 at 06:53

2 Answers2

2

Unsure why your device takes so much time other than its running around in circles like a headless chicken before falling over.

Your error feedback should give you a clue by reporting the file is too large for an image:

sfdp: graph is too large for cairo-renderer bitmaps. Scaling by 0.531958 to fit  
sfdp: failure to create cairo surface: out of memory  

Here it is as SVG, note the size is roughly 600 in square that's roughly 61,598 pixels x 51,767 pixels = roughly 3GB (your error says 3142361088 bytes cannot be Memory ALLOCated)

A large file by any standard, but as SVG its only 1.63 MB

sfdp -Goverlap=scale -x -Tsvg syscall -o data.svg

File: data.svg File Size: 1.63 MB (1,707,939 Bytes) Number of Pages: 1 Page Size: 641.64 x 539.24 in

enter image description here

You can open the svg in a browser and print to PDF HOWEVER even at 10% scale on A0 Landscape that requires 2 PAGES and you cant see lettering, thus at full scale it would be more than 100 of those poster pages enter image description here enter image description here

kirogasa
  • 627
  • 5
  • 19
K J
  • 8,045
  • 3
  • 14
  • 36
1

Add this to your input file: graph [nslimit=2 nslimit1=2 maxiter=5000] (values somewhat arbitrary)
And use this commandline dot -v -Tsvg ... (if svg works, then try pdf)
I think dot has the best chance of producing a graph you will like

sroush
  • 5,375
  • 2
  • 5
  • 11
  • please can you explain the meaning of the lines... and where exactly should I add them – Abhishek Ghosh Sep 25 '22 at 17:20
  • *why exactly should I add them – Abhishek Ghosh Sep 25 '22 at 17:40
  • Add them at the top of the file (after the 1st line.) They should speed up execution. They are mentioned (lightly) here https://graphviz.org/pdf/dotguide.pdf and https://graphviz.org/doc/info/attrs.html. See what the dot engine does. – sroush Sep 25 '22 at 18:52
  • ```network simplex: 270700 nodes 406273 edges 2852 iter 23.61 sec Segmentation fault (core dumped)``` Don't why, but I got a segmentation fault while running `dot -v -Tsvg syscall > syscall.svg` – Abhishek Ghosh Sep 25 '22 at 19:00
  • 270700 nodes and 406273 edges is a very large graph. Seemingly too large for dot. You might create an issue here https://gitlab.com/graphviz/graphviz/-/issues and see if the developers have any thoughts – sroush Sep 25 '22 at 21:36