Translating Factor graphs into DOT


The graphviz.dot vocabulary implements a word to translate Factor graph objects into equivalent DOT code (see http://graphviz.org/content/dot-language).
write-dot ( graph path encoding -- )


Because the data structure of Factor graph objects so closely maps to the DOT language, the translation is straightforward. This also means that rendering Factor graphs using the graphviz.render vocabulary should generally work exactly as though you had written the DOT code to start with.

However, there is one limitation. Though Graphviz documentation claims that there's no semantic difference between quoted and unquoted identifiers, there are a few cases that make a difference. write-dot will always quote identifiers, since it's the safest option:
Quoting prevents clashes with builtin DOT keywords.
Quoting lets identifiers use whitespace.


But there are a couple things to keep in mind:
Quotes in strings will be escaped (and null-terminators "\0" removed), but otherwise Factor strings are printed as usual. So "a\nb" will print a newline in the DOT code, not a literal 'backslash n'. This is handy anyway, because certain Graphviz layout engines will parse escape codes in DOT that Factor doesn't know about. For instance, to use the Graphviz escape sequence "\l", you have to use the Factor string "\\l".
Node port syntax doesn't work when node names are quoted. Instead, use the edge's headport and tailport attributes (see graphviz.attributes).
HTML-like labels, which must use angle brackets (<...>) instead of quotes ("..."), are currently unsupported.