File: sample11.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 (42 lines) | stat: -rw-r--r-- 896 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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/ruby

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

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

graph["compound"] = "true"
graph.edge["lhead"] = ""
graph.edge["ltail"] = ""

c0 = graph.add_graph( "cluster0" )
a = c0.add_nodes( "a" )
b = c0.add_nodes( "b" )
c = c0.add_nodes( "c" )
d = c0.add_nodes( "d" )
c0.add_edges( a, b )
c0.add_edges( a, c )
c0.add_edges( b, d )
c0.add_edges( c, d )

c1 = graph.add_graph( "cluster1" )
e = c1.add_nodes( "e" )
f = c1.add_nodes( "f" )
g = c1.add_nodes( "g" )
c1.add_edges( e, g )
c1.add_edges( e, f )

h = graph.add_nodes( "h" )

graph.add_edges( b, f, "lhead" => "cluster1" )
graph.add_edges( d, e )
graph.add_edges( c, g, "ltail" => "cluster0", "lhead" => "cluster1" )
graph.add_edges( c, e, "ltail" => "cluster0" )
graph.add_edges( d, h )

graph.output( :png => "#{$0}.png" )