lib/rgl/dot.rb in rgl-0.2.3 vs lib/rgl/dot.rb in rgl-0.3.0

- old
+ new

@@ -1,8 +1,8 @@ # dot.rb # -# $Id: dot.rb,v 1.5 2005/02/04 22:41:46 monora Exp $ +# $Id: dot.rb,v 1.7 2008/02/26 06:01:22 javanthropus Exp $ # # Minimal Dot support, based on Dave Thomas's dot module (included in rdoc). # rdot.rb is a modified version which also contains support for undirected # graphs. @@ -21,17 +21,17 @@ fontsize = params['fontsize'] ? params['fontsize'] : '8' graph = (directed? ? DOT::DOTDigraph : DOT::DOTSubgraph).new(params) edge_class = directed? ? DOT::DOTDirectedEdge : DOT::DOTEdge each_vertex do |v| name = v.to_s - graph << DOT::DOTNode.new('name' => '"' + name + '"', + graph << DOT::DOTNode.new('name' => name, 'fontsize' => fontsize, 'label' => name) end each_edge do |u,v| - graph << edge_class.new('from' => '"'+ u.to_s + '"', - 'to' => '"'+ v.to_s + '"', + graph << edge_class.new('from' => u.to_s, + 'to' => v.to_s, 'fontsize' => fontsize) end graph end @@ -39,22 +39,22 @@ def print_dotted_on (params = {}, s = $stdout) s << to_dot_graph(params).to_s << "\n" end - # Call +dotty+ for the graph which is written to the file 'graph.dot' + # Call dotty[http://www.graphviz.org] for the graph which is written to the file 'graph.dot' # in the # current directory. def dotty (params = {}) dotfile = "graph.dot" File.open(dotfile, "w") {|f| print_dotted_on(params, f) } system("dotty", dotfile) end - # Use +do+ to create a graphical representation of the graph. Returns the - # filename of the graphics file. + # Use dot[http://www.graphviz.org] to create a graphical representation of + # the graph. Returns the filename of the graphics file. def write_to_graphic_file (fmt='png', dotfile="graph") src = dotfile + ".dot" dot = dotfile + "." + fmt