write.dot: Export tree to a Graphviz DOT format

View source: R/export.R

write.dotR Documentation

Export tree to a Graphviz DOT format

Description

Exports the vistla tree in a DOT format, which can be later layouted and rendered by Graphviz programs like dot or neato.

Usage

write.dot(
  x,
  con,
  vstyle = list(shape = function(x) ifelse(x$depth < 0, "egg", ifelse(x$leaf, "box",
    "ellipse")), label = function(x) sprintf("\"%s\"", x$name)),
  estyle = list(penwidth = function(x) sprintf("%0.3f", 0.5 + x$score/max(x$score) *
    2.5)),
  gstyle = list(overlap = "\"prism\"", splines = "true"),
  direction = c("none", "fromY", "intoY")
)

Arguments

x

vistla object.

con

connection; passed to writeLines. If missing, the DOT code is returned as a character vector.

vstyle

vertex attribute list — should be a named list of Graphviz attributes like shape or penwidth. For elements which are strings or numbers, the value is copied as is as an attribute value. For elements which functions, though, the function is called on a vistla_tree object and should return a vector of values.

estyle

edge attribute list, behaves exactly like vstyle. When functions are called, the Y-vertex is not present.

gstyle

graph attribute list. Functions are not supported here.

direction

when set to "none", graph is undirected, otherwise directed, for "fromY", root is a source, while for "intoY", a sink.

Value

For a missing con argument, a character vector with the graph in the DOT format, invisible NULL otherwise.

Note

Graphviz attribute values can be either strings, like "some vertex" in label, or atoms, like box for shape. When returning a string value, you must supply quotes, otherwise it will be included as an atom.

The default value of gstyle may invoke long layout calculations in Graphviz. Change to list() for a fast but less aesthetic layout.

The function does no validation whether provided attributes or values are correct.

References

"An open graph visualization system and its applications to software engineering" E.R. Gansner, S.C. North. Software: Practice and Experience 30:1203-1233 (2000).


vistla documentation built on Sept. 28, 2024, 1:08 a.m.

Related to write.dot in vistla...