Are GraphViz dot files deterministic?
Asked Answered
H

2

7

I am making some GraphViz dot graphs within my source code using Doxygen.

Question: Are the graphs produced by a specific dot file guaranteed to always produce the same output?

Is this the case for different computers, at different times of day, on different architectures, etc?

I am considering using compass points to refine my graph and make it look nicer.

I am wondering if there is any "randomness" to the initial seeding of the graph layout, or any "implementation-defined" portions to the layout engine. I don't want to go to a lot of effort to optimize output for my system, if it won't look the same on others systems. This will be used by both Windows and Mac users. TIA

Homebrew answered 22/2, 2013 at 6:57 Comment(9)
afaik dot engine is deterministic, implemented in portable C. But guaranteed is a strong word, I think you can't expect someone reliably guarantees anything in SW, go figure for free...Creuse
@CapelliC, Thanks for the answer. Yes guaranteed is a strong word. Maybe I meant guaranteed* (* as long as the conditions in the fine print are met). Any info on when it wouldn't be the same are appreciated.Homebrew
So far I never seen any randomness, but I used just dot. Some other engine relies on iterative randomic computation, but in statistical sense, thus 'deterministic' on convergence. HTHCreuse
Different versions of dot may produce different output. Given that your doxygen instance may not be exactly synchronised, there is a possibility that the output will not match. In the case of some of the other layout engines, there are further options to randomly seed the layout, but this does not apply to dot.Estonian
The documentation says you can seed the RNG for the neato, twopi, and fdp layouts; however it says nothing about the dot layout.Duda
For the dot engine GV 2.38 I experienced nondeterministic behaviour if clusters were involved. Horizontal cluster order was random.Lording
I have also seen non-deterministic behaviour in 2.38 with clusters. For what it's worth, it doesn't seem to be hitting any rand() calls, so I wonder if it's simply an uninitialised data bug.Roseannroseanna
Some more on this issue here in the pygraphviz google group - groups.google.com/forum/#!topic/pygraphviz-discuss/fv6chP39lA0Vickeyvicki
Anecdotally, I too have seen nondeterminism in Graphviz. I'm using clusters. I'm on Graphviz 2.47.0. I have integration tests which ultimately test the output of the Graphviz SVG renderer. It is common that SVG XML elements are output in a non-deterministic order (which is inconsequential to the rendered image). But I've also seen it (very rarely, and typically for highly-symmetrical graphs) switch round the position of Graphviz nodes, resulting in a different rendered image. Unfortunately, it's a very hard issue to reproduce.Raab
E
1

I 've experimenting a lot with different rendering environment like online / cli.

You have a good chance to get different results if you use different graphviz versions. Within a same version I never have had problems of non-deterministics in dot graphs.

Another topic could be, if you use special utf-fonts, which could be rendered on different system different. For e.g. emoji-Flags rendering on windows vs. mac/unix.

Perhaps the wrapper / calling tools like doxygen / understand / pygraph / jgraph / gograph etc. pp. could be a source for different dot-files on different system.

I would state the dot-graph itself is very deterministic within the same version.

Edmundoedmunds answered 16/3, 2018 at 1:45 Comment(0)
G
1

I believe, by default the graphs produced from graphviz are deterministic because the initial node placement and the solver are such. To generate a different image, The graph attribute 'start' is set to rand.

Ref: https://www.graphviz.org/pdf/neatoguide.pdf

Gemmation answered 27/6, 2019 at 4:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.