Version: 0.1.9 Release date: 2001-11-16 Home page: http://rockit.sf.net/subprojects/graphr Tarball: http://prdownloads.sf.net/rockit/graphr-0-1-9.tar.gz Author: Robert Feldt Email: feldt@ce.chalmers.se
GraphR is very simple but is growing to support additional features of dot. A larger, "full" graph package is now being developed together with Horst Duchene so expect more features in the future...
GraphViz is an open source graph drawing software from AT&T (see http://www.research.att.com/sw/tools/graphviz/).
You can uninstall with: ruby install.rb --uninstall
# Lets crank out a simple graph... require 'graph/graphviz_dot' # We create a DotGraphPrinter from some links. # In this simple example we don't even have a "real" graph # just an Array with the links. The optional third # element of a link is link information. The nodes in this graph # are implicit in the links. If we had additional nodes that were # not linked we would supply them in an array as 2nd parameter to new. links = [[:start, 1, "*"], [1, 1, "a"], [1, 2, "~a"], [2, :stop, "*"]] dgp = DotGraphPrinter.new(links) # We specialize the printer to change the shape of nodes # based on their names. dgp.node_shaper = proc{|n| ["start", "stop"].include?(n.to_s) ? "doublecircle" : "box" } # We can also set the attributes on individual nodes and edges. # These settings override the default shapers and labelers. dgp.set_node_attributes(2, :shape => "diamond") # Add URL link from node (this only work in some output formats?) # Note the extra quotes needed! dgp.set_node_attributes(2, :URL => '"node2.html"') # And now output to files dgp.write_to_file("g.png", "png") # Generate png file dgp.orientation = "landscape" # Dot problem with PS orientation dgp.write_to_file("g.ps") # Generate postscript file
Dot is only a part of GraphViz. Download at http://www.research.att.com/sw/tools/graphviz/download.html and make sure dot can be run from Ruby by doing
system "dot"
ie. that dot is installed somewhere in the PATH.
NOTE THAT THIS IS AN ALPHA RELEASE SO THERE WILL LIKELY BE BUGS. And the API will probably change in future versions.
Copyright (c) 2001 Robert Feldt, feldt@ce.chalmers.se. All rights reserved.
and is distributed under GPL. See LICENSE.
Thanks for Tanaka Akira for the code for strongly connected components and to Johan Holmberg for a patch.
Thanks to Sean Russell, Tobias Reif and Horst Duchene for feedback on and ideas for GraphR.
Happy coding!
Robert Feldt, feldt@ce.chalmers.se