luquet-ruby-graphviz 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +7 -0
- data/COPYING +340 -0
- data/ChangeLog +66 -0
- data/README.rdoc +69 -0
- data/bin/ruby2gv +194 -0
- data/examples/HTML-Labels.rb +20 -0
- data/examples/arrowhead.rb +97 -0
- data/examples/dot/cluster.dot +31 -0
- data/examples/dot/fsm.dot +20 -0
- data/examples/dot/genetic.dot +118 -0
- data/examples/dot/hello.dot +1 -0
- data/examples/dot/hello_test.rb +14 -0
- data/examples/dot/lion_share.dot +103 -0
- data/examples/dot/prof.dot +150 -0
- data/examples/dot/psg.dot +28 -0
- data/examples/dot/sdh.dot +284 -0
- data/examples/dot/siblings.dot +492 -0
- data/examples/dot/test.dot +17 -0
- data/examples/dot/unix.dot +104 -0
- data/examples/graphviz.org/TrafficLights.rb +62 -0
- data/examples/graphviz.org/cluster.rb +62 -0
- data/examples/graphviz.org/hello_world.rb +10 -0
- data/examples/graphviz.org/lion_share.rb +215 -0
- data/examples/graphviz.org/process.rb +37 -0
- data/examples/maketest.sh +85 -0
- data/examples/p2p.rb +35 -0
- data/examples/sample01.rb +32 -0
- data/examples/sample02.rb +42 -0
- data/examples/sample03.rb +31 -0
- data/examples/sample04.rb +22 -0
- data/examples/sample05.rb +32 -0
- data/examples/sample06.rb +46 -0
- data/examples/sample07.rb +23 -0
- data/examples/sample08.rb +34 -0
- data/examples/sample09.rb +50 -0
- data/examples/sample10.rb +50 -0
- data/examples/sample11.rb +42 -0
- data/examples/sample12.rb +55 -0
- data/examples/sample13.rb +48 -0
- data/examples/sample14.rb +44 -0
- data/examples/sample15.rb +23 -0
- data/examples/sample16.rb +8 -0
- data/examples/sample17.rb +92 -0
- data/examples/sample18.rb +24 -0
- data/examples/sample19.rb +59 -0
- data/examples/sample20.rb +47 -0
- data/examples/sample21.rb +12 -0
- data/examples/sample22.rb +10 -0
- data/examples/sample23.rb +11 -0
- data/examples/sample24.rb +11 -0
- data/examples/sample25.rb +11 -0
- data/examples/shapes.rb +24 -0
- data/examples/test.xml +26 -0
- data/examples/testorder.rb +43 -0
- data/examples/testxml.rb +7 -0
- data/lib/graphviz.rb +655 -0
- data/lib/graphviz/attrs.rb +51 -0
- data/lib/graphviz/constants.rb +246 -0
- data/lib/graphviz/dot.treetop +97 -0
- data/lib/graphviz/edge.rb +130 -0
- data/lib/graphviz/node.rb +129 -0
- data/lib/graphviz/parser.rb +249 -0
- data/lib/graphviz/xml.rb +131 -0
- data/setup.rb +1585 -0
- metadata +176 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
# http://www.graphviz.org/Gallery/undirected/process.html
|
2
|
+
#
|
3
|
+
# graph G {
|
4
|
+
# run -- intr;
|
5
|
+
# intr -- runbl;
|
6
|
+
# runbl -- run;
|
7
|
+
# run -- kernel;
|
8
|
+
# kernel -- zombie;
|
9
|
+
# kernel -- sleep;
|
10
|
+
# kernel -- runmem;
|
11
|
+
# sleep -- swap;
|
12
|
+
# swap -- runswap;
|
13
|
+
# runswap -- new;
|
14
|
+
# runswap -- runmem;
|
15
|
+
# new -- runmem;
|
16
|
+
# sleep -- runmem;
|
17
|
+
# }
|
18
|
+
|
19
|
+
$:.unshift( "../../lib" );
|
20
|
+
require "graphviz"
|
21
|
+
|
22
|
+
GraphViz::new( :G, :type => :graph ) { |g|
|
23
|
+
g._new[:label] = "new"
|
24
|
+
g.run << g.intr
|
25
|
+
g.intr << g.runbl
|
26
|
+
g.runbl << g.run
|
27
|
+
g.run << g.kernel
|
28
|
+
g.kernel << g.zombie
|
29
|
+
g.kernel << g.sleep
|
30
|
+
g.kernel << g.runmem
|
31
|
+
g.sleep << g.swap
|
32
|
+
g.swap << g.runswap
|
33
|
+
g.runswap << g._new
|
34
|
+
g.runswap << g.runmem
|
35
|
+
g._new << g.runmem
|
36
|
+
g.sleep << g.runmem
|
37
|
+
}.output( :png => "process.png", :use => :fdp )
|
@@ -0,0 +1,85 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
echo "arrowhead.rb"
|
4
|
+
ruby arrowhead.rb $1
|
5
|
+
echo "HTML-Labels.rb"
|
6
|
+
ruby HTML-Labels.rb
|
7
|
+
echo "p2p.rb"
|
8
|
+
ruby p2p.rb $1
|
9
|
+
|
10
|
+
echo "sample01.rb"
|
11
|
+
ruby sample01.rb $1
|
12
|
+
echo "sample02.rb"
|
13
|
+
ruby sample02.rb $1
|
14
|
+
echo "sample03.rb"
|
15
|
+
ruby sample03.rb $1
|
16
|
+
echo "sample04.rb"
|
17
|
+
ruby sample04.rb $1
|
18
|
+
echo "sample05.rb"
|
19
|
+
ruby sample05.rb $1
|
20
|
+
echo "sample06.rb"
|
21
|
+
ruby sample06.rb
|
22
|
+
echo "sample07.rb"
|
23
|
+
ruby sample07.rb $1
|
24
|
+
echo "sample08.rb"
|
25
|
+
ruby sample08.rb $1
|
26
|
+
echo "sample09.rb"
|
27
|
+
ruby sample09.rb $1
|
28
|
+
echo "sample10.rb"
|
29
|
+
ruby sample10.rb $1
|
30
|
+
echo "sample11.rb"
|
31
|
+
ruby sample11.rb $1
|
32
|
+
echo "sample12.rb"
|
33
|
+
ruby sample12.rb $1
|
34
|
+
echo "sample13.rb"
|
35
|
+
ruby sample13.rb
|
36
|
+
echo "sample14.rb"
|
37
|
+
ruby sample14.rb
|
38
|
+
echo "sample15.rb"
|
39
|
+
ruby sample15.rb
|
40
|
+
echo "sample16.rb"
|
41
|
+
ruby sample16.rb
|
42
|
+
echo "sample17.rb"
|
43
|
+
ruby sample17.rb
|
44
|
+
echo "sample18.rb"
|
45
|
+
ruby sample18.rb
|
46
|
+
echo "sample19.rb"
|
47
|
+
ruby sample19.rb
|
48
|
+
echo "sample20.rb"
|
49
|
+
ruby sample20.rb
|
50
|
+
echo "sample21.rb"
|
51
|
+
ruby sample21.rb
|
52
|
+
echo "sample22.rb"
|
53
|
+
ruby sample22.rb
|
54
|
+
echo "sample23.rb"
|
55
|
+
ruby sample23.rb
|
56
|
+
echo "sample24.rb"
|
57
|
+
ruby sample24.rb
|
58
|
+
echo "sample25.rb"
|
59
|
+
ruby sample25.rb
|
60
|
+
|
61
|
+
echo "shapes.rb"
|
62
|
+
ruby shapes.rb $1
|
63
|
+
echo "testorder.rb"
|
64
|
+
ruby testorder.rb $1
|
65
|
+
echo "testxml.rb"
|
66
|
+
ruby testxml.rb $1
|
67
|
+
|
68
|
+
cd dot
|
69
|
+
pwd
|
70
|
+
echo "dot/hello_test.rb"
|
71
|
+
ruby hello_test.rb
|
72
|
+
cd ..
|
73
|
+
|
74
|
+
cd graphviz.org
|
75
|
+
echo "graphviz.org/cluster.rb"
|
76
|
+
ruby cluster.rb
|
77
|
+
echo "graphviz.org/hello_world.rb"
|
78
|
+
ruby hello_world.rb
|
79
|
+
echo "graphviz.org/lion_share.rb"
|
80
|
+
ruby lion_share.rb
|
81
|
+
echo "graphviz.org/process.rb"
|
82
|
+
ruby process.rb
|
83
|
+
echo "graphviz.org/TrafficLights.rb"
|
84
|
+
ruby TrafficLights.rb
|
85
|
+
cd ..
|
data/examples/p2p.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
g = nil
|
7
|
+
if ARGV[0]
|
8
|
+
g = GraphViz::new( "G", "path" => ARGV[0], :use => "circo" )
|
9
|
+
else
|
10
|
+
g = GraphViz::new( "G" )
|
11
|
+
end
|
12
|
+
|
13
|
+
c0 = g.add_graph( "cluster0" )
|
14
|
+
c0["label"] = "Environnement de Brad !"
|
15
|
+
c0["style"] = "filled"
|
16
|
+
c0["color"] = "blue"
|
17
|
+
|
18
|
+
ja = c0.add_node( "Jennifer_Aniston", :style => "filled", :color => "red" )
|
19
|
+
bp = c0.add_node( "Brad_Pitt", :style => "filled", :color => "white" )
|
20
|
+
aj = c0.add_node( "Angelina_Jolie", :style => "filled", :color => "green" )
|
21
|
+
|
22
|
+
c0.add_edge( ja, bp ) # On ete mariés
|
23
|
+
c0.add_edge( bp, aj ) # Sont ensemble
|
24
|
+
|
25
|
+
jv = g.add_node( "John_Voight", :label => "John Voight", :shape => "rectangle" )
|
26
|
+
md = g.add_node( "Madonna" )
|
27
|
+
gr = g.add_node( "Guy_Ritchie" )
|
28
|
+
|
29
|
+
g.add_edge( aj, jv ) # est la fille de
|
30
|
+
g.add_edge( jv, aj ) # est le pere de
|
31
|
+
g.add_edge( bp, jv, :color => "red", :label => "Est le beau fils de" ) # Beau fils
|
32
|
+
g.add_edge( bp, gr )
|
33
|
+
g.add_edge( gr, md )
|
34
|
+
|
35
|
+
g.output( :png => "p2p.png" )
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
g = nil
|
7
|
+
if ARGV[0]
|
8
|
+
g = GraphViz::new( "G", :path => ARGV[0] )
|
9
|
+
else
|
10
|
+
g = GraphViz::new( "G" )
|
11
|
+
end
|
12
|
+
|
13
|
+
main = g.add_node( "main" )
|
14
|
+
parse = g.add_node( "parse" )
|
15
|
+
execute = g.add_node( "execute" )
|
16
|
+
init = g.add_node( "init" )
|
17
|
+
cleanup = g.add_node( "cleanup" )
|
18
|
+
make_string = g.add_node( "make_string" )
|
19
|
+
printf = g.add_node( "printf" )
|
20
|
+
compare = g.add_node( "compare" )
|
21
|
+
|
22
|
+
g.add_edge( main, parse )
|
23
|
+
g.add_edge( parse, execute )
|
24
|
+
g.add_edge( main, init )
|
25
|
+
g.add_edge( main, cleanup )
|
26
|
+
g.add_edge( execute, make_string )
|
27
|
+
g.add_edge( execute, printf )
|
28
|
+
g.add_edge( init, make_string )
|
29
|
+
g.add_edge( main, printf )
|
30
|
+
g.add_edge( execute, compare )
|
31
|
+
|
32
|
+
g.output( :png => "#{$0}.png" )
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
g = nil
|
7
|
+
if ARGV[0]
|
8
|
+
g = GraphViz::new( "G", :path => ARGV[0] )
|
9
|
+
else
|
10
|
+
g = GraphViz::new( "G" )
|
11
|
+
end
|
12
|
+
|
13
|
+
g.node[:shape] = "ellipse"
|
14
|
+
g.node[:color] = "black"
|
15
|
+
|
16
|
+
g.edge[:color] = "black"
|
17
|
+
g.edge[:weight] = "1"
|
18
|
+
g.edge[:style] = "filled"
|
19
|
+
g.edge[:label] = ""
|
20
|
+
|
21
|
+
g[:size] = "4,4"
|
22
|
+
|
23
|
+
main = g.add_node( "main", :shape => "box" )
|
24
|
+
parse = g.add_node( "parse" )
|
25
|
+
execute = g.add_node( "execute" )
|
26
|
+
init = g.add_node( "init" )
|
27
|
+
cleanup = g.add_node( "cleanup" )
|
28
|
+
make_string = g.add_node( "make_string", :label => 'make a\nstring' )
|
29
|
+
printf = g.add_node( "printf" )
|
30
|
+
compare = g.add_node( "compare", :shape => "box", :style => "filled", :color => ".7 .3 1.0" )
|
31
|
+
|
32
|
+
g.add_edge( main, parse, :weight => "8" )
|
33
|
+
g.add_edge( parse, execute )
|
34
|
+
g.add_edge( main, init, :style => "dotted" )
|
35
|
+
g.add_edge( main, cleanup )
|
36
|
+
g.add_edge( execute, make_string )
|
37
|
+
g.add_edge( execute, printf )
|
38
|
+
g.add_edge( init, make_string )
|
39
|
+
g.add_edge( main, printf, :color => "red", :style => "bold", :label => "100 times" )
|
40
|
+
g.add_edge( execute, compare, :color => "red" )
|
41
|
+
|
42
|
+
g.output( :png => "#{$0}.png" )
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
g = nil
|
7
|
+
if ARGV[0]
|
8
|
+
g = GraphViz::new( "G", "path" => ARGV[0] )
|
9
|
+
else
|
10
|
+
g = GraphViz::new( "G" )
|
11
|
+
end
|
12
|
+
|
13
|
+
g.node["shape"] = "ellipse"
|
14
|
+
g.node["sides"] = "4"
|
15
|
+
g.node["peripheries"] = ""
|
16
|
+
g.node["color"] = "black"
|
17
|
+
g.node["style"] = ""
|
18
|
+
g.node["skew"] = "0.0"
|
19
|
+
g.node["distortion"] = "0.0"
|
20
|
+
|
21
|
+
a = g.add_node( "a", "shape" => "polygon", "sides" => "5", "peripheries" => "3", "color" => "lightblue", "style" => "filled" )
|
22
|
+
b = g.add_node( "b" )
|
23
|
+
c = g.add_node( "c", "shape" => "polygon", "sides" => "4", "skew" => ".4", "label" => "hello world" )
|
24
|
+
d = g.add_node( "d", "shape" => "invtriangle" )
|
25
|
+
e = g.add_node( "e", "shape" => "polygon", "sides" => "4", "distortion" => ".7" )
|
26
|
+
|
27
|
+
g.add_edge( a, b )
|
28
|
+
g.add_edge( b, c )
|
29
|
+
g.add_edge( b, d )
|
30
|
+
|
31
|
+
g.output( :png => "#{$0}.png" )
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
g = nil
|
7
|
+
if ARGV[0]
|
8
|
+
g = GraphViz::new( "structs", "path" => ARGV[0] )
|
9
|
+
else
|
10
|
+
g = GraphViz::new( "structs" )
|
11
|
+
end
|
12
|
+
|
13
|
+
g.node["shape"] = "record"
|
14
|
+
|
15
|
+
struct1 = g.add_node( "struct1", "shape" => "record", "label" => "<f0> left|<f1> mid\ dle|<f2> right" )
|
16
|
+
struct2 = g.add_node( "struct2", "shape" => "record", "label" => "<f0> one|<f1> two" )
|
17
|
+
struct3 = g.add_node( "struct3", "shape" => "record", "label" => 'hello\nworld |{ b |{c|<here> d|e}| f}| g | h' )
|
18
|
+
|
19
|
+
g.add_edge( struct1, struct2 )
|
20
|
+
g.add_edge( struct1, struct3 )
|
21
|
+
|
22
|
+
g.output( :png => "#{$0}.png" )
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
g = nil
|
7
|
+
if ARGV[0]
|
8
|
+
g = GraphViz::new( "structs", "type" => "graph", "path" => ARGV[0] )
|
9
|
+
else
|
10
|
+
g = GraphViz::new( "structs", "type" => "graph" )
|
11
|
+
end
|
12
|
+
|
13
|
+
main = g.add_node( "main" )
|
14
|
+
parse = g.add_node( "parse" )
|
15
|
+
execute = g.add_node( "execute" )
|
16
|
+
init = g.add_node( "init" )
|
17
|
+
cleanup = g.add_node( "cleanup" )
|
18
|
+
make_string = g.add_node( "make_string" )
|
19
|
+
printf = g.add_node( "printf" )
|
20
|
+
compare = g.add_node( "compare" )
|
21
|
+
|
22
|
+
g.add_edge( main, parse )
|
23
|
+
g.add_edge( parse, execute )
|
24
|
+
g.add_edge( main, init )
|
25
|
+
g.add_edge( main, cleanup )
|
26
|
+
g.add_edge( execute, make_string )
|
27
|
+
g.add_edge( execute, printf )
|
28
|
+
g.add_edge( init, make_string )
|
29
|
+
g.add_edge( main, printf )
|
30
|
+
g.add_edge( execute, compare )
|
31
|
+
|
32
|
+
g.output( :png => "#{$0}.png" )
|
@@ -0,0 +1,46 @@
|
|
1
|
+
$:.unshift( "../lib" );
|
2
|
+
require "graphviz"
|
3
|
+
|
4
|
+
GraphViz::new( "G", :rankdir => "LR", :type => "graph" ) { |graph|
|
5
|
+
graph.cluster0 { |cluster|
|
6
|
+
cluster[:label] = "Back Office"
|
7
|
+
|
8
|
+
cluster.fatman.set { |n|
|
9
|
+
n.label = "FatMan"
|
10
|
+
n.shape = "rect"
|
11
|
+
}
|
12
|
+
cluster.grobil.set { |n|
|
13
|
+
n.label = "GroBil"
|
14
|
+
n.shape = "rect"
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
graph.cluster1 { |cluster|
|
19
|
+
cluster[:label] = "DMZ"
|
20
|
+
|
21
|
+
cluster.dupont.set { |n|
|
22
|
+
n.label = "Dupont"
|
23
|
+
n.shape = "rect"
|
24
|
+
}
|
25
|
+
cluster.dupond.set { |n|
|
26
|
+
n.label = "Dupond"
|
27
|
+
n.shape = "rect"
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
graph.cluster2() { |cluster|
|
32
|
+
cluster[:label] = "Front Office"
|
33
|
+
|
34
|
+
cluster.door.set { |n|
|
35
|
+
n.label = "Door"
|
36
|
+
n.shape = "rect"
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
graph.cluster0.fatman << graph.cluster1.dupont
|
41
|
+
graph.cluster0.fatman << graph.cluster1.dupond
|
42
|
+
graph.cluster0.grobil << graph.cluster1.dupont
|
43
|
+
graph.cluster0.grobil << graph.cluster1.dupond
|
44
|
+
graph.cluster1.dupont << graph.cluster2.door
|
45
|
+
graph.cluster1.dupond << graph.cluster2.door
|
46
|
+
}.output( :path => '/usr/local/bin/', :png => "#{$0}.png" )
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
GraphViz::options( :use => "dot" )
|
7
|
+
|
8
|
+
if ARGV[0]
|
9
|
+
GraphViz::options( :path => ARGV[0] )
|
10
|
+
end
|
11
|
+
|
12
|
+
g = GraphViz::new( "structs" )
|
13
|
+
|
14
|
+
g.node["shape"] = "record"
|
15
|
+
|
16
|
+
g.add_node( "struct1", "shape" => "record", "label" => "<f0> left|<f1> middle|<f2> right" )
|
17
|
+
g.add_node( "struct2", "shape" => "record", "label" => "<f0> one|<f1> two" )
|
18
|
+
g.add_node( "struct3", "shape" => "record", "label" => 'hello\nworld |{ b |{c|<here> d|e}| f}| g | h' )
|
19
|
+
|
20
|
+
g.add_edge( "struct1:f1", "struct2:f0" )
|
21
|
+
g.add_edge( "struct1:f2", "struct3:here" )
|
22
|
+
|
23
|
+
g.output( :png => "#{$0}.png", :canon => nil )
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
g = nil
|
7
|
+
if ARGV[0]
|
8
|
+
g = GraphViz::new( "G" "nodesep" => ".05", "rankdir" => "LR", "path" => ARGV[0] )
|
9
|
+
else
|
10
|
+
g = GraphViz::new( "G", "nodesep" => ".05", "rankdir" => "LR" )
|
11
|
+
end
|
12
|
+
|
13
|
+
g.node["shape"] = "record"
|
14
|
+
g.node["width"] = ".1"
|
15
|
+
g.node["height"] = ".1"
|
16
|
+
|
17
|
+
g.add_node( "node0", "label" => "<f0> |<f1> |<f2> |<f3> |<f4> |<f5> |<f6> |<f7> | ", "height" => "2.5" )
|
18
|
+
g.add_node( "node1", "label" => "{<n> n14 | 719 |<p> }", "width" => "1.5" )
|
19
|
+
g.add_node( "node2", "label" => "{<n> a1 | 805 |<p> }", "width" => "1.5" )
|
20
|
+
g.add_node( "node3", "label" => "{<n> i9 | 718 |<p> }", "width" => "1.5" )
|
21
|
+
g.add_node( "node4", "label" => "{<n> e5 | 989 |<p> }", "width" => "1.5" )
|
22
|
+
g.add_node( "node5", "label" => "{<n> t20 | 959 |<p> }", "width" => "1.5" )
|
23
|
+
g.add_node( "node6", "label" => "{<n> o15 | 794 |<p> }", "width" => "1.5" )
|
24
|
+
g.add_node( "node7", "label" => "{<n> s19 | 659 |<p> }", "width" => "1.5" )
|
25
|
+
|
26
|
+
g.add_edge( "node0:f0", "node1:n" )
|
27
|
+
g.add_edge( "node0:f1", "node2:n" )
|
28
|
+
g.add_edge( "node0:f2", "node3:n" )
|
29
|
+
g.add_edge( "node0:f5", "node4:n" )
|
30
|
+
g.add_edge( "node0:f6", "node5:n" )
|
31
|
+
g.add_edge( "node2:p", "node6:n" )
|
32
|
+
g.add_edge( "node4:p", "node7:n" )
|
33
|
+
|
34
|
+
g.output( :png => "#{$0}.png" )
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
g = nil
|
7
|
+
if ARGV[0]
|
8
|
+
g = GraphViz::new( "G", "path" => ARGV[0] )
|
9
|
+
else
|
10
|
+
g = GraphViz::new( "G" )
|
11
|
+
end
|
12
|
+
|
13
|
+
g.node["shape"] = "ellipse"
|
14
|
+
g.node["color"] = "black"
|
15
|
+
|
16
|
+
g["color"] = "black"
|
17
|
+
|
18
|
+
c0 = g.add_graph( "cluster0" )
|
19
|
+
c0["label"] = "process #1"
|
20
|
+
c0["style"] = "filled"
|
21
|
+
c0["color"] = "lightgrey"
|
22
|
+
a0 = c0.add_node( "a0", "style" => "filled", "color" => "white" )
|
23
|
+
a1 = c0.add_node( "a1", "style" => "filled", "color" => "white" )
|
24
|
+
a2 = c0.add_node( "a2", "style" => "filled", "color" => "white" )
|
25
|
+
a3 = c0.add_node( "a3", "style" => "filled", "color" => "white" )
|
26
|
+
c0.add_edge( a0, a1 )
|
27
|
+
c0.add_edge( a1, a2 )
|
28
|
+
c0.add_edge( a2, a3 )
|
29
|
+
|
30
|
+
c1 = g.add_graph( "cluster1", "label" => "process #2" )
|
31
|
+
b0 = c1.add_node( "b0", "style" => "filled", "color" => "blue" )
|
32
|
+
b1 = c1.add_node( "b1", "style" => "filled", "color" => "blue" )
|
33
|
+
b2 = c1.add_node( "b2", "style" => "filled", "color" => "blue" )
|
34
|
+
b3 = c1.add_node( "b3", "style" => "filled", "color" => "blue" )
|
35
|
+
c1.add_edge( b0, b1 )
|
36
|
+
c1.add_edge( b1, b2 )
|
37
|
+
c1.add_edge( b2, b3 )
|
38
|
+
|
39
|
+
start = g.add_node( "start", "shape" => "Mdiamond" )
|
40
|
+
endn = g.add_node( "end", "shape" => "Msquare" )
|
41
|
+
|
42
|
+
g.add_edge( start, a0 )
|
43
|
+
g.add_edge( start, b0 )
|
44
|
+
g.add_edge( a1, b3 )
|
45
|
+
g.add_edge( b2, a3 )
|
46
|
+
g.add_edge( a3, a0 )
|
47
|
+
g.add_edge( a3, endn )
|
48
|
+
g.add_edge( b3, endn )
|
49
|
+
|
50
|
+
g.output( :png => "#{$0}.png" )
|