Skip to content
This repository

Ruby interface to the GraphViz graphing tool

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 bin
Octocat-spinner-32 examples
Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 AUTHORS
Octocat-spinner-32 COPYING
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 setup.rb
README.rdoc

Ruby/GraphViz

Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Gregoire Lejeune

DESCRIPTION

Interface to the GraphViz graphing tool

CHANGELOG

0.9.11 :

  • Issue #11 : Cygwin PATH

  • Major bugs correction in output

  • Bug correction in find_executable

  • Add tests (by Chip Malice : github.com/hipe)

  • TODO: GraphViz::Parser support block

  • TODO: Issue #12

0.9.10 :

  • Move ChangeLog in README

  • Add GraphViz::FamilyTree (alpha). See examples/sample33.rb

  • Major bugs corrections in GraphViz::Parser

  • Issue #10 : Anonymous graph (see Subgraphs and Clusters at www.graphviz.org/doc/info/lang.html). See examples/sample34.rb

  • GraphViz#add_graph can now take a block parameter. See example/sample34.rb

  • Add GraphViz.digraph and GraphViz.graph (same as GraphViz.new( …, :type => “digraph” ) and GraphViz.new( …, :type => “graph” )). See examples/sample35.rb

  • Add GraphViz#subgraph. See examples/sample35.rb

  • GraphViz::Parser support anonymous graph

  • Add lage node example. See examples/sample36.rb

0.9.9 :

  • Add graph as an accessor to allow you to set global graph attributs (like edge and node)

  • Add each_node, each_edge, each_graph (thanks to @metellius) and graph_count

  • Issue #9 (partial) - Solution : by default, a node will have his label set with the node ID)

0.9.8 :

  • Update graph and node posibility to set properties (see sample28.rb)

  • Issue #7: Path option is never being used to find the executable

  • Adding classes to check if the attributes are in the correct type

  • Issue #8: dots in href are escaped with backslash, which corrupts the URL (see sample29.rb)

  • Add posibility to use external libraries (see sample30.rb)

  • Add options -u and -s to ruby2gv

  • Add gem2gv

0.9.7 :

  • Issue #2: Small bug correction in escape_path_containing_blanks (by Andreas Ronge)

  • Issue #4: New find_executable (by reactive)

  • Issue #3: Tempfiles created in current working directory only in Windows

  • Issue #6: Respect “none” format in output options hash and respect String output-filename when the “none” format is selected. See examples/sample27.rb (by Dave Burt)

0.9.6 :

  • jRuby support (by obruening)

  • Issue #1 : STDOUT in binmode

0.9.5 :

  • Remove 'mkmf' dependency

  • GraphViz::Edge#[] modification

  • Small correction to escape the dot ('.') character (by Miguel Cabrera)

0.9.4 :

  • Escape nodes and edges attributs

  • GraphViz::escape corrections (by Dave Burt)

  • Add :errors option to set level of message suppression (default : suppress warning messages)

0.9.3 :

  • Minor bug correction for Windows

  • Use Open3.popen3 if installed, else use IO.popen (by Dave Burt)

  • Add '-', '>' and '>>' has aliases of '<<' to create an edge.

0.9.2 :

  • Escape nodes (by Dave Burt)

  • Handle errors from graphviz command (by Dave Burt)

  • Output as string (if String class is passed as file i.e. output(:pdf => String)) (by Dave Burt)

0.9.1 :

  • Bugs corrections

  • Add the ability to create edge like that : node1 << node2 << node3 …

  • Complete README

  • Add a DOT parser. This parser has a lot of limitations. So don't use it in a production context !

  • :output and :file options are deprecated, please use :<format> => :<file>

  • You can now specify multiple outputs via :<format> => :<file> (see sample 22).

0.9.0 :

  • Add fdp example (sample 15)

  • Add edge between cluster and node and cluster and cluster support

  • GraphViz.add_node now support array (sample 16)

  • Bug correction in GraphViz.output (sample 19)

  • Add GraphViz#default to set default options (:use, :path and :output)

  • Add possibility to set node or edge attribut via :

node.<attribut>=<value> or node.<attribut>( <value> ) adge.<attribut>=<value> or adge.<attribut>( <value> )

  • Add GraphViz::Edge.set and GraphViz::Node.set

  • Add sample 20

  • Add GraphViz.node_count and GraphViz.edge_count by Daniel Cadenas Nión

0.8.2 :

0.8.1 :

  • Documentation

0.8.0 :

  • Add all the features of the current graphviz version

0.7.0 :

  • Add option “path” to output

0.6.0 :

  • Add undirected graph support

0.5.0 :

  • Preserve the original order of creation of nodes and edges

0.4.0 :

  • Add HTML-Labels

0.3.0 :

  • Bugs corrections

0.2.0 :

  • Pure ruby

0.1.0 :

  • Initial version

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")

Ruby/GraphViz also include :

  • ruby2gv, a simple tool that's allow you to create a dependency graph from a ruby script. Example : drp.ly/dShaZ

ruby2gv -Tpng -oruby2gv.png ruby2gv

  • gem2gv, a tools that's allow you to create a dependency graph between gems. Example : drp.ly/dSj9Y

gem2gv -Tpng -oruby-graphviz.png ruby-graphviz

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.

Something went wrong with that request. Please try again.