Method: RGL::Graph#write_to_graphic_file
- Defined in:
- lib/rgl/dot.rb
#write_to_graphic_file(fmt = 'png', dotfile = "graph", options = {}) ⇒ Object
Use dot to create a graphical representation of the graph. Returns the filename of the graphics file.
116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/rgl/dot.rb', line 116 def write_to_graphic_file(fmt = 'png', dotfile = "graph", = {}) src = dotfile + ".dot" dot = dotfile + "." + fmt File.open(src, 'w') do |f| f << self.to_dot_graph().to_s << "\n" end unless system("dot -T#{fmt} #{src} -o #{dot}") raise "Error executing dot. Did you install GraphViz?" end dot end |