`generate_dot()` uses single quotes instead of double quotes
atchley-sha opened this issue · comments
Using the generate_dot()
function, the output uses single quotes around every attribute value, which (as far as I can tell) isn't supported in the dot
language. Writing the output of generate_dot()
to a file and subsequently running dot
from a command line on that file throws a syntax error.
For example:
g <- create_graph() %>%
add_node() %>%
add_node() %>%
add_edge(1,2)
generate_dot(g) %>% writeLines("test.dot")
produces
digraph {
graph [layout = 'neato',
outputorder = 'edgesfirst',
bgcolor = 'white']
node [fontname = 'Helvetica',
fontsize = '10',
shape = 'circle',
fixedsize = 'true',
width = '0.5',
style = 'filled',
fillcolor = 'aliceblue',
color = 'gray70',
fontcolor = 'gray50']
edge [fontname = 'Helvetica',
fontsize = '8',
len = '1.5',
color = 'gray80',
arrowsize = '0.5']
'1'
'2'
'1'->'2'
}
and dot -Tpng test.dot -o test.png
from a command line gives Error: test.dot: syntax error in line 3 near '''
. However, replacing the single quotes with double quotes (e.g. with str_replace("'", "\"")
) produces a file that does work with command-line dot
.
It seems to me that generate_dot()
should use double quotes by default since that's what dot
expects.