Ruby/GraphViz

Copyright © 2004, 2005, 2006, 2007, 2008, 2009 Gregoire Lejeune

DESCRIPTION

Interface to the GraphViz graphing tool

SYNOPSIS

A basic example

require 'graphviz'
# Create a new graph
g = GraphViz.new( :G, :type => :digraph )
# Create two nodes
hello = g.add_node( "Hello" )
world = g.add_node( "World" )
# Create an edge between the two nodes
g.add_edge( hello, world )
# Generate output image
g.output( :png => "hello_world.png" )

The same but with a block

require 'graphviz'
GraphViz::new( :G, :type => :digraph ) { |g|
  g.world( :label => "World" ) << g.hello( :label => "Hello" )
}.output( :png => "hello_world.png" )

Create a graph from a file

require 'graphviz'
# In this example, hello.dot is :
#   digraph G {Hello->World;}
GraphViz.parse( "hello.dot", :path => "/usr/local/bin" ) { |g|
  g.get_node("Hello") { |n|
    n[:label] = "Bonjour"
  }
  g.get_node("World") { |n|
    n[:label] = "Le Monde"
  }
}.output(:png => "sample.png")

INSTALLATION

sudo gem install ruby-graphviz

You also need to install GraphViz and Treetop

On Windows you also need to install win32-open3. This is not an absolute requirement.

LICENCE

Ruby/GraphViz is freely distributable according to the terms of the GNU General Public License (see the file ‘COPYING’).

This program is distributed without any warranty. See the file ‘COPYING’ for details.