File: sample07.rb

package info (click to toggle)
ruby-graphviz 1.0.8-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,124 kB
  • ctags: 695
  • sloc: ruby: 7,656; xml: 26; makefile: 17
file content (23 lines) | stat: -rw-r--r-- 649 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/ruby

$:.unshift( "../lib" );
require "graphviz"

GraphViz::options( :use => "dot" )

if ARGV[0]
  GraphViz::options( :path => ARGV[0] )
end

g = GraphViz::new( "structs" )

g.node["shape"] = "record"

g.add_nodes( "struct1", "shape" => "record", "label" => "<f0> left|<f1> middle|<f2> right" )
g.add_nodes( "struct2", "shape" => "record", "label" => "<f0> one|<f1> two" )
g.add_nodes( "struct3", "shape" => "record", "label" => 'hello\nworld |{ b |{c|<here> d|e}| f}| g | h' )

g.add_edges( { "struct1" => :f1}, {"struct2" => :f0} )
g.add_edges( {"struct1" => :f2}, {"struct3" => :here} )

g.output( :png => "#{$0}.png", :canon => nil )