Sha256: 69d6f6105a1b5069e8ce3b776f76c21ff0bd2f6c8b85b70403d943b776a5b70f

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

#!/usr/bin/ruby

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

g = nil
if ARGV[0]
  g = GraphViz::new( "G", "output" => "png", "path" => ARGV[0] )
else
  g = GraphViz::new( "G", "output" => "png" )
end

g.node[:shape] = "ellipse"
g.node[:color] = "black"

g[:color] = "black"

g.cluster0( ) do |cluster|
  cluster[:label] = "process #1"
  cluster[:style] = "filled"
  cluster[:color] = "lightgrey"
  
  cluster.a0 :style => "filled", :color => "white"
  cluster.a1 :style => "filled", :color => "white"
  cluster.a2 :style => "filled", :color => "white"
  cluster.a3 :style => "filled", :color => "white"
  
  cluster.a0 << cluster.a1
  cluster.a1 << cluster.a2
  cluster.a2 << cluster.a3
end

g.cluster1( :label => "process #2" ) do |cluster|
  cluster.b0 :style => "filled", :color => "blue"
  cluster.b1 :style => "filled", :color => "blue"
  cluster.b2 :style => "filled", :color => "blue"
  cluster.b3 :style => "filled", :color => "blue"
  
  cluster.b0 << cluster.b1
  cluster.b1 << cluster.b2
  cluster.b2 << cluster.b3
end

g.start :shape => "Mdiamond"
g.endn :shape => "Msquare"

## THIS DON'T WORK !!!
#g.start << g.cluster0.a0
#g.start << g.cluster1.b0
#g.cluster0.a1 << g.cluster1.b3
#g.cluster1.b2 << g.cluster0.a3
#g.cluster0.a3 << g.cluster0.a0
#g.cluster0.a3 << g.endn
#g.cluster1.b3 << g.endn

g.add_edge( g.start, g.cluster0.a0 )
g.add_edge( g.start, g.cluster1.b0 )
g.add_edge( g.cluster0.a1, g.cluster1.b3 )
g.add_edge( g.cluster1.b2, g.cluster0.a3 )
g.add_edge( g.cluster0.a3, g.cluster0.a0 )
g.add_edge( g.cluster0.a3, g.endn )
g.add_edge( g.cluster1.b3, g.endn )

g.output

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-graphviz-0.8.1 examples/sample12.rb