Loading a DOT file using RGL - ruby

RGL supports writing DOT files from a graph, is it possible to create a graph from a DOT file?
(Obviously I can parse the DOT file myself and create a graph, but I'm wondering if this functionality exists already).

First you have to install graphviz which gives you the 'dot' command.
Then you can run
dot -Tpng graph.dot > output.png
but I found that after installing dot the rgl method write_to_graphic_file automatically writes the image if you do something like
graph_obj.write_to_graphic_file('png')

Related

Why is graphviz producing a corrupted image file?

I am using graphviz to create a png file, however when I run my the code, after it generates the image, I try to open the file only to receive a message that either the image file type (png) is unsupported, which I tested using other pngs so I know that can't be the case, or that the file is corrupted. The code I'm running is as follows:
dot -Tpng test.dot -o test.png
with test.dot being:
graph G {
fontname="Helvetica,Arial,sans-serif"
node [fontname="Helvetica,Arial,sans-serif"]
edge [fontname="Helvetica,Arial,sans-serif"]
layout=fdp
"Infinity Blade" -- "Undertow";
"Infinity Blade" -- "Shadow Complex";
.
.
.
"Calvin and Hobbes" -- "XKCD";
"XKCD" -- "Enders Game";
}
When running the code I did also receive two messages, however neither of them had resulted in a corrupted file the first time I received them:
Warning: Overlap value "prism" unsupported - ignored
dot: graph is too large for cairo-renderer bitmaps. Scaling by 0.404306 to fit

Overwrite attributes from DOT file in commandline with graphviz

I have graphviz installed on a linux VM. I am automatically converting .apt into .dot files using APT. I draw these with graphviz and the dot command. But it keeps showing the xlabels, which are set automatically by APT. Is there a way to surpress these xlabels, so they dont show ?
-Gforcelabels=false didn't work and i could not change the labels with -Exlabel
dot -Nxlabel="" -Exlabel="" -T... should(?) work, but it does not! I consider this a bug, not a feature.
This does work:
gvpr -c 'E{$.xlabel=""}N{$.xlabel=""}' file.dot |dot -Tsvg >file.svg

Cannot open .dot file gvEdit

I cannot open the attached dot file in gvEdit.
I tried to convert it to png file
dot -Tpng final.dot > finalgraph.png
it gives me the following problem:
dot: graph is too large for cairo-renderer bitmaps. Scaling by 0.311296 to fit
dot: failure to create cairo surface: out of memory
My purpose is only to view the dot file, how should I resolve it?
The dot file is here:
https://www.dropbox.com/s/vt2q653x2x9jjbj/final.dot?dl=0

Generating a file path

Does anyone know a tool for showing the path from one file to another? Ie, if my css file is in:
/User/foo/bar/source/assets/myscreen
and my image is in:
/User/foo/bar/gamethings/smallimages
How can I quickly, without having to count the file levels (which is simple, but tedious, and has to be done often), generate the path from the css to the image?
First, get realpath(1) from GNU Coreutils. Then:
$ realpath --relative-to=/User/foo/bar/source/assets/myscreen /User/foo/bar/gamethings/smallimages
../../../gamethings/smallimages

graphviz pdf generation from .dot failing with both Tpdf and Tps2

I have a .dpt file I am trying to output a .png and .pdf files out of it and I am using my command line expression as: dot -Tpng SPU123.dot -o SPU123.png to generate .png and it works fine. First, I tried to generate (following graphviz documentation) .pdf by: dot -Tpdf SPU123.dot -o SPU123.pdf but it just generated a blank .pdf and the documentation says there is something buggy with Tpdf option and instead use Tps2 option so I did: dot -Tps SPU123.dot -o SPU123.ps but I got this error:
Error: canvas size (34642,3608) exceeds PDF limit (14400)
(suggest setting a bounding box size, see dot(1))
How to generate .pdf output out of my .dot file?

Resources